]> granicus.if.org Git - python/commitdiff
Merged revisions 84210 via svnmerge from
authorSenthil Kumaran <orsenthil@gmail.com>
Thu, 19 Aug 2010 17:54:33 +0000 (17:54 +0000)
committerSenthil Kumaran <orsenthil@gmail.com>
Thu, 19 Aug 2010 17:54:33 +0000 (17:54 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r84210 | senthil.kumaran | 2010-08-19 23:20:31 +0530 (Thu, 19 Aug 2010) | 3 lines

  Fix Issue9639 - reset the retry count on successful auth.
........

Lib/urllib/request.py

index 0e62d9f0b29ccacd087e7d3653bc631c82e6a2a1..4beafc16320baa2e7918b6952fdf36f0392c424b 100644 (file)
@@ -778,6 +778,9 @@ class AbstractBasicAuthHandler:
         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
@@ -817,8 +820,10 @@ class HTTPBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
 
     def http_error_401(self, req, fp, code, msg, headers):
         url = req.full_url
-        return self.http_error_auth_reqed('www-authenticate',
+        response = self.http_error_auth_reqed('www-authenticate',
                                           url, req, headers)
+        self.reset_retry_count()
+        return response
 
 
 class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
@@ -831,8 +836,10 @@ class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
         # should not, RFC 3986 s. 3.2.1) support requests for URLs containing
         # userinfo.
         authority = req.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):