def build_request
head = @req.headers ? munge_header_keys(@req.headers) : {}
if @conn.connopts.http_proxy?
proxy = @conn.connopts.proxy
head['proxy-authorization'] = proxy[:authorization] if proxy[:authorization]
end
if cookie = head['cookie']
@cookies << encode_cookie(cookie) if cookie
end
head['cookie'] = @cookies.compact.uniq.join("; ").squeeze(";") unless @cookies.empty?
if !@req.keepalive
head['connection'] = 'close'
end
head['host'] ||= encode_host
head['user-agent'] ||= "EventMachine HttpClient"
head['Authorization'] = @req.uri.userinfo.split(/:/, 2) if @req.uri.userinfo
head
end