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
STDERR.puts "ERROR reading http body: #$!"
$!.backtrace.join("\n")
@socket.close rescue Object
@body.delete if @body.class == Tempfile
@body = nil
end
end