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