Fix Issue1595365 - Adding the req.headers after the un-redirect headers have

been added. This helps in accidental overwritting of User-Agent header to
default value. To preserve the old behavior, only headers not in unredirected
headers will be updated.
This commit is contained in:
Senthil Kumaran 2010-09-27 01:26:03 +00:00
parent cb15988114
commit 42ef4b1f4c
2 changed files with 16 additions and 2 deletions

View file

@ -1063,8 +1063,10 @@ class AbstractHTTPHandler(BaseHandler):
raise URLError('no host given')
h = http_class(host, timeout=req.timeout) # will parse host:port
headers = dict(req.headers)
headers.update(req.unredirected_hdrs)
headers = dict(req.unredirected_hdrs)
headers.update(dict((k, v) for k, v in req.headers.items()
if k not in headers))
# TODO(jhylton): Should this be redesigned to handle
# persistent connections?