247: def read_body(remain, total)
248: begin
249:
250: @params.http_body = read_socket(remain % Const::CHUNK_SIZE)
251:
252: remain -= @body.write(@params.http_body)
253:
254: update_request_progress(remain, total)
255:
256:
257: until remain <= 0 or @socket.closed?
258:
259: @params.http_body = read_socket(Const::CHUNK_SIZE)
260: remain -= @body.write(@params.http_body)
261:
262: update_request_progress(remain, total)
263: end
264: rescue Object
265: STDERR.puts "ERROR reading http body: #$!"
266: $!.backtrace.join("\n")
267:
268: @socket.close rescue Object
269: @body.delete if @body.class == Tempfile
270: @body = nil
271: end
272: end