Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cb39d6c

Browse files
committed
Merged revisions 84210 via svnmerge from
svn+ssh://[email protected]/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. ........
1 parent a5154ad commit cb39d6c

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

Lib/urllib/request.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,9 @@ def __init__(self, password_mgr=None):
778778
self.add_password = self.passwd.add_password
779779
self.retried = 0
780780

781+
def reset_retry_count(self):
782+
self.retried = 0
783+
781784
def http_error_auth_reqed(self, authreq, host, req, headers):
782785
# host may be an authority (without userinfo) or a URL with an
783786
# authority
@@ -817,8 +820,10 @@ class HTTPBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
817820

818821
def http_error_401(self, req, fp, code, msg, headers):
819822
url = req.full_url
820-
return self.http_error_auth_reqed('www-authenticate',
823+
response = self.http_error_auth_reqed('www-authenticate',
821824
url, req, headers)
825+
self.reset_retry_count()
826+
return response
822827

823828

824829
class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
@@ -831,8 +836,10 @@ def http_error_407(self, req, fp, code, msg, headers):
831836
# should not, RFC 3986 s. 3.2.1) support requests for URLs containing
832837
# userinfo.
833838
authority = req.host
834-
return self.http_error_auth_reqed('proxy-authenticate',
839+
response = self.http_error_auth_reqed('proxy-authenticate',
835840
authority, req, headers)
841+
self.reset_retry_count()
842+
return response
836843

837844

838845
def randombytes(n):

0 commit comments

Comments
 (0)