From efcd883735af264ff6acbb642e2d2e3fb50b8e81 Mon Sep 17 00:00:00 2001 From: Senthil Kumaran Date: Wed, 24 Feb 2010 16:56:20 +0000 Subject: [PATCH] Merged revisions 78426 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r78426 | senthil.kumaran | 2010-02-24 22:23:16 +0530 (Wed, 24 Feb 2010) | 9 lines Merged revisions 78422 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78422 | senthil.kumaran | 2010-02-24 22:15:46 +0530 (Wed, 24 Feb 2010) | 2 lines Fix for Issue3819 - urllib2 sends Basic auth across redirects ........ ................ --- Lib/test/test_urllib2.py | 3 ++- Lib/urllib/request.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py index 66ef0d6c83..f0297a5537 100644 --- a/Lib/test/test_urllib2.py +++ b/Lib/test/test_urllib2.py @@ -1145,7 +1145,8 @@ class HandlerTests(unittest.TestCase): base64.encodebytes(userpass).strip().decode()) self.assertEqual(http_handler.requests[1].get_header(auth_header), 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 # handle the HTTP auth error password_manager.user = password_manager.password = None diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 9e02962a02..d1d12e6569 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -795,7 +795,7 @@ class AbstractBasicAuthHandler: auth = "Basic " + base64.b64encode(raw.encode()).decode("ascii") if req.headers.get(self.auth_header, None) == auth: 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) else: return None -- 2.40.0