summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2002-10-11 17:26:46 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2002-10-11 17:26:46 (GMT)
commit96f1129de80c6cddba7a45db86eb09579221704e (patch)
tree56039d61fcae0ffb3cfc3c6ac6917650c4920a3f /Lib
parenta0f453b2b14df707532a584c27fcfc158f233d4b (diff)
downloadcpython-96f1129de80c6cddba7a45db86eb09579221704e.zip
cpython-96f1129de80c6cddba7a45db86eb09579221704e.tar.gz
cpython-96f1129de80c6cddba7a45db86eb09579221704e.tar.bz2
Fix for SF bug #599836: Don't duplicate headers.
If the request object has a header, it should override the default header provided by the OpenerDirector.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/urllib2.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/urllib2.py b/Lib/urllib2.py
index 2b01e8c..a8fcc35 100644
--- a/Lib/urllib2.py
+++ b/Lib/urllib2.py
@@ -247,7 +247,7 @@ class Request:
class OpenerDirector:
def __init__(self):
server_version = "Python-urllib/%s" % __version__
- self.addheaders = [('User-agent', server_version)]
+ self.addheaders = [('User-Agent', server_version)]
# manage the individual handlers
self.handlers = []
self.handle_open = {}
@@ -771,7 +771,8 @@ class AbstractHTTPHandler(BaseHandler):
sel_host, sel_path = splithost(sel)
h.putheader('Host', sel_host or host)
for args in self.parent.addheaders:
- h.putheader(*args)
+ if name not in req.headers:
+ h.putheader(*args)
for k, v in req.headers.items():
h.putheader(k, v)
h.endheaders()