def send_request_header
query = @options[:query]
head = @options[:head] ? munge_header_keys(@options[:head]) : {}
body = normalize_body
request_header = nil
if @state == :response_proxy
proxy = @options[:proxy]
head = proxy[:head] ? munge_header_keys(proxy[:head]) : {}
head['proxy-authorization'] = proxy[:authorization] if proxy[:authorization]
request_header = HTTP_REQUEST_HEADER % ['CONNECT', "#{@uri.host}:#{@uri.port}"]
elsif websocket?
head['upgrade'] = 'WebSocket'
head['connection'] = 'Upgrade'
head['origin'] = @options[:origin] || @uri.host
else
head['content-length'] = body.bytesize if body
if cookie = head.delete('cookie')
head['cookie'] = encode_cookie(cookie)
end
if not head['content-type'] and options[:body].is_a? Hash
head['content-type'] = "application/x-www-form-urlencoded"
end
end
head['host'] ||= encode_host
head['user-agent'] ||= "EventMachine HttpClient"
request_header ||= encode_request(@method, @uri.path, query, @uri.query)
request_header << encode_headers(head)
request_header << CRLF
send_data request_header
end