summaryrefslogtreecommitdiffstats
path: root/Lib/urllib
diff options
context:
space:
mode:
authorSenthil Kumaran <orsenthil@gmail.com>2010-09-27 01:26:03 (GMT)
committerSenthil Kumaran <orsenthil@gmail.com>2010-09-27 01:26:03 (GMT)
commit42ef4b1f4c8f07357f7c4e9cb8470f57365b0ffa (patch)
tree1d2fa130f808aaa59e11354bf1445cc9d12348c3 /Lib/urllib
parentcb159881148812b6a842748ecc8c820402e9df65 (diff)
downloadcpython-42ef4b1f4c8f07357f7c4e9cb8470f57365b0ffa.zip
cpython-42ef4b1f4c8f07357f7c4e9cb8470f57365b0ffa.tar.gz
cpython-42ef4b1f4c8f07357f7c4e9cb8470f57365b0ffa.tar.bz2
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.
Diffstat (limited to 'Lib/urllib')
-rw-r--r--Lib/urllib/request.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index 16d8125..6c6450f 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -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?