[Python-checkins] r84207 - python/branches/release27-maint/Lib/urllib2.py

senthil.kumaran python-checkins at python.org
Thu Aug 19 19:32:03 CEST 2010


Author: senthil.kumaran
Date: Thu Aug 19 19:32:03 2010
New Revision: 84207

Log:
Fix - Issue9639: Reset the retry counter after successful authentication.



Modified:
   python/branches/release27-maint/Lib/urllib2.py

Modified: python/branches/release27-maint/Lib/urllib2.py
==============================================================================
--- python/branches/release27-maint/Lib/urllib2.py	(original)
+++ python/branches/release27-maint/Lib/urllib2.py	Thu Aug 19 19:32:03 2010
@@ -822,6 +822,9 @@
         self.add_password = self.passwd.add_password
         self.retried = 0
 
+    def reset_retry_count(self):
+        self.retried = 0
+
     def http_error_auth_reqed(self, authreq, host, req, headers):
         # host may be an authority (without userinfo) or a URL with an
         # authority
@@ -861,8 +864,10 @@
 
     def http_error_401(self, req, fp, code, msg, headers):
         url = req.get_full_url()
-        return self.http_error_auth_reqed('www-authenticate',
-                                          url, req, headers)
+        response = self.http_error_auth_reqed('www-authenticate',
+                                              url, req, headers)
+        self.reset_retry_count()
+        return response
 
 
 class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
@@ -875,8 +880,10 @@
         # should not, RFC 3986 s. 3.2.1) support requests for URLs containing
         # userinfo.
         authority = req.get_host()
-        return self.http_error_auth_reqed('proxy-authenticate',
+        response = self.http_error_auth_reqed('proxy-authenticate',
                                           authority, req, headers)
+        self.reset_retry_count()
+        return response
 
 
 def randombytes(n):


More information about the Python-checkins mailing list