Commit 67a62a41 authored by Senthil Kumaran's avatar Senthil Kumaran

Fix Issue9639 - reset the retry count on successful auth.

parent 92dc80a8
...@@ -778,6 +778,9 @@ class AbstractBasicAuthHandler: ...@@ -778,6 +778,9 @@ class AbstractBasicAuthHandler:
self.add_password = self.passwd.add_password self.add_password = self.passwd.add_password
self.retried = 0 self.retried = 0
def reset_retry_count(self):
self.retried = 0
def http_error_auth_reqed(self, authreq, host, req, headers): def http_error_auth_reqed(self, authreq, host, req, headers):
# host may be an authority (without userinfo) or a URL with an # host may be an authority (without userinfo) or a URL with an
# authority # authority
...@@ -817,8 +820,10 @@ class HTTPBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler): ...@@ -817,8 +820,10 @@ class HTTPBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
def http_error_401(self, req, fp, code, msg, headers): def http_error_401(self, req, fp, code, msg, headers):
url = req.full_url url = req.full_url
return self.http_error_auth_reqed('www-authenticate', response = self.http_error_auth_reqed('www-authenticate',
url, req, headers) url, req, headers)
self.reset_retry_count()
return response
class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler): class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
...@@ -831,8 +836,10 @@ 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 # should not, RFC 3986 s. 3.2.1) support requests for URLs containing
# userinfo. # userinfo.
authority = req.host authority = req.host
return self.http_error_auth_reqed('proxy-authenticate', response = self.http_error_auth_reqed('proxy-authenticate',
authority, req, headers) authority, req, headers)
self.reset_retry_count()
return response
def randombytes(n): def randombytes(n):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment