mirror of
https://github.com/python/cpython.git
synced 2024-11-25 19:03:49 +08:00
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.
This commit is contained in:
parent
a0f453b2b1
commit
96f1129de8
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user