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
if !head.key?('user-agent')
head['user-agent'] = 'EventMachine HttpClient'
elsif head['user-agent'].nil?
head.delete('user-agent')
end
if !head.key?('accept-encoding') && req.compressed
head['accept-encoding'] = 'gzip, compressed'
end
head['Authorization'] = @req.uri.userinfo.split(/:/, 2) if @req.uri.userinfo
head
end