def read_body(remain, total)
begin
@params.http_body = read_socket(remain % Const::CHUNK_SIZE)
remain -= @body.write(@params.http_body)
update_request_progress(remain, total)
until remain <= 0 or @socket.closed?
@params.http_body = read_socket(Const::CHUNK_SIZE)
remain -= @body.write(@params.http_body)
update_request_progress(remain, total)
end
rescue Object => e
STDERR.puts "#{Time.now}: Error reading HTTP body: #{e.inspect}"
STDERR.puts e.backtrace.join("\n")
@socket.close rescue nil
@body.delete if @body.class == Tempfile
@body = nil
end
end