Handle cases where a user-agent was set via headers

unstable
HD Moore 2012-05-31 14:58:47 -05:00
parent 2ad17299e2
commit 03b65c6a48
1 changed files with 6 additions and 0 deletions

View File

@ -145,6 +145,11 @@ class Client
c_conn = opts['connection'] c_conn = opts['connection']
c_auth = opts['basic_auth'] || config['basic_auth'] || '' c_auth = opts['basic_auth'] || config['basic_auth'] || ''
# An agent parameter was specified, but so was a header, prefer the header
if c_ag and c_head.keys.map{|x| x.downcase }.include?('user-agent')
c_ag = nil
end
uri = set_uri(c_uri) uri = set_uri(c_uri)
req = '' req = ''
@ -164,6 +169,7 @@ class Client
req << set_host_header(c_host) req << set_host_header(c_host)
req << set_agent_header(c_ag) req << set_agent_header(c_ag)
if (c_auth.length > 0) if (c_auth.length > 0)
req << set_basic_auth_header(c_auth) req << set_basic_auth_header(c_auth)
end end