def send_request(head, body)
body = normalize_body(body)
file = @req.file
query = @req.query
head['content-length'] = File.size(file) if file
if body
head['content-length'] = body.bytesize
elsif @req.method == 'POST' or @req.method == 'PUT'
head['content-length'] ||= 0
end
if not head['content-type'] and @req.body.is_a? Hash
head['content-type'] = 'application/x-www-form-urlencoded'
end
request_header ||= encode_request(@req.method, @req.uri, query, @conn.connopts.proxy)
request_header << encode_headers(head)
request_header << CRLF
@conn.send_data request_header
if body
@conn.send_data body
elsif @req.file
@conn.stream_file_data @req.file, :http_chunks => false
end
end