From 96f1129de80c6cddba7a45db86eb09579221704e Mon Sep 17 00:00:00 2001 From: Jeremy Hylton Date: Fri, 11 Oct 2002 17:26:46 +0000 Subject: 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. --- Lib/urllib2.py | 5 +++-- 1 file 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() -- cgit v0.12