diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2010-06-01 12:56:17 (GMT) |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2010-06-01 12:56:17 (GMT) |
commit | efafdc7d103c6773621c8d200935939a672a127d (patch) | |
tree | 7563acdfa017c8f84e59c08296873649ecda0981 /Lib/urllib | |
parent | a68fc7a7c2c4ab700c5583cc40ac0fa4d8b58774 (diff) | |
download | cpython-efafdc7d103c6773621c8d200935939a672a127d.zip cpython-efafdc7d103c6773621c8d200935939a672a127d.tar.gz cpython-efafdc7d103c6773621c8d200935939a672a127d.tar.bz2 |
Merged revisions 81638 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r81638 | senthil.kumaran | 2010-06-01 18:23:48 +0530 (Tue, 01 Jun 2010) | 9 lines
Merged revisions 81636 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r81636 | senthil.kumaran | 2010-06-01 18:10:07 +0530 (Tue, 01 Jun 2010) | 3 lines
Fix Issue8797 - urllib2 basic authentication fix for wrong passwords. It fails after 5 retries.
........
................
Diffstat (limited to 'Lib/urllib')
-rw-r--r-- | Lib/urllib/request.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 5440efb..95e8e33 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -775,12 +775,21 @@ class AbstractBasicAuthHandler: password_mgr = HTTPPasswordMgr() self.passwd = password_mgr self.add_password = self.passwd.add_password + 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 # XXX could be multiple headers authreq = headers.get(authreq, None) + + if self.retried > 5: + # retry sending the username:password 5 times before failing. + raise HTTPError(req.get_full_url(), 401, "basic auth failed", + headers, None) + else: + self.retried += 1 + if authreq: mo = AbstractBasicAuthHandler.rx.search(authreq) if mo: |