Merged revisions 85025 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r85025 | senthil.kumaran | 2010-09-27 06:56:03 +0530 (Mon, 27 Sep 2010) | 6 lines
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.
........
diff --git a/Lib/urllib2.py b/Lib/urllib2.py
index 5c717a4..adc6d8c 100644
--- a/Lib/urllib2.py
+++ b/Lib/urllib2.py
@@ -1127,8 +1127,10 @@
h = http_class(host, timeout=req.timeout) # will parse host:port
h.set_debuglevel(self._debuglevel)
- 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))
+
# We want to make an HTTP/1.1 request, but the addinfourl
# class isn't prepared to deal with a persistent connection.
# It will try to read all remaining data from the socket,