[Python-checkins] r78422 - in python/trunk/Lib: test/test_urllib2.py urllib2.py
senthil.kumaran
python-checkins at python.org
Wed Feb 24 17:45:46 CET 2010
Author: senthil.kumaran
Date: Wed Feb 24 17:45:46 2010
New Revision: 78422
Log:
Fix for Issue3819 - urllib2 sends Basic auth across redirects
Modified:
python/trunk/Lib/test/test_urllib2.py
python/trunk/Lib/urllib2.py
Modified: python/trunk/Lib/test/test_urllib2.py
==============================================================================
--- python/trunk/Lib/test/test_urllib2.py (original)
+++ python/trunk/Lib/test/test_urllib2.py Wed Feb 24 17:45:46 2010
@@ -1134,7 +1134,8 @@
auth_hdr_value = 'Basic '+base64.encodestring(userpass).strip()
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
Modified: python/trunk/Lib/urllib2.py
==============================================================================
--- python/trunk/Lib/urllib2.py (original)
+++ python/trunk/Lib/urllib2.py Wed Feb 24 17:45:46 2010
@@ -839,7 +839,7 @@
auth = 'Basic %s' % base64.b64encode(raw).strip()
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
More information about the Python-checkins
mailing list