Commit 96f1129d authored by Jeremy Hylton's avatar Jeremy Hylton

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.
parent a0f453b2
......@@ -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()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment