diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2010-08-19 17:54:33 (GMT) |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2010-08-19 17:54:33 (GMT) |
commit | cb39d6c4e23df99f7a6d101a08b21ff898f13ac8 (patch) | |
tree | dc6533625d73c7e59be6df44ff4797f1ba969622 | |
parent | a5154ad1790cdc0c5518e1df56733d52b2ba213d (diff) | |
download | cpython-cb39d6c4e23df99f7a6d101a08b21ff898f13ac8.zip cpython-cb39d6c4e23df99f7a6d101a08b21ff898f13ac8.tar.gz cpython-cb39d6c4e23df99f7a6d101a08b21ff898f13ac8.tar.bz2 |
Merged revisions 84210 via svnmerge from
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.
........
-rw-r--r-- | Lib/urllib/request.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 0e62d9f..4beafc1 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -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): |