Fix for Issue3819 - urllib2 sends Basic auth across redirects
This commit is contained in:
parent
2d9856d6ce
commit
8526adfbd9
|
@ -1134,7 +1134,8 @@ class HandlerTests(unittest.TestCase):
|
||||||
auth_hdr_value = 'Basic '+base64.encodestring(userpass).strip()
|
auth_hdr_value = 'Basic '+base64.encodestring(userpass).strip()
|
||||||
self.assertEqual(http_handler.requests[1].get_header(auth_header),
|
self.assertEqual(http_handler.requests[1].get_header(auth_header),
|
||||||
auth_hdr_value)
|
auth_hdr_value)
|
||||||
|
self.assertEqual(http_handler.requests[1].unredirected_hdrs[auth_header],
|
||||||
|
auth_hdr_value)
|
||||||
# if the password manager can't find a password, the handler won't
|
# if the password manager can't find a password, the handler won't
|
||||||
# handle the HTTP auth error
|
# handle the HTTP auth error
|
||||||
password_manager.user = password_manager.password = None
|
password_manager.user = password_manager.password = None
|
||||||
|
|
|
@ -839,7 +839,7 @@ class AbstractBasicAuthHandler:
|
||||||
auth = 'Basic %s' % base64.b64encode(raw).strip()
|
auth = 'Basic %s' % base64.b64encode(raw).strip()
|
||||||
if req.headers.get(self.auth_header, None) == auth:
|
if req.headers.get(self.auth_header, None) == auth:
|
||||||
return None
|
return None
|
||||||
req.add_header(self.auth_header, auth)
|
req.add_unredirected_header(self.auth_header, auth)
|
||||||
return self.parent.open(req, timeout=req.timeout)
|
return self.parent.open(req, timeout=req.timeout)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in New Issue