Mercurial > public > mercurial-scm > hg-stable
diff mercurial/url.py @ 11876:1fe94103c6ee
Merge with stable
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Sat, 14 Aug 2010 03:30:35 +0200 |
parents | d4bfa07f269f 6c51a5056020 |
children | e3526634d5a3 |
line wrap: on
line diff
--- a/mercurial/url.py Sat Aug 14 03:28:45 2010 +0200 +++ b/mercurial/url.py Sat Aug 14 03:30:35 2010 +0200 @@ -570,6 +570,25 @@ return raise +class httpbasicauthhandler(urllib2.HTTPBasicAuthHandler): + def __init__(self, *args, **kwargs): + urllib2.HTTPBasicAuthHandler.__init__(self, *args, **kwargs) + self.retried_req = None + + def reset_retry_count(self): + # Python 2.6.5 will call this on 401 or 407 errors and thus loop + # forever. We disable reset_retry_count completely and reset in + # http_error_auth_reqed instead. + pass + + def http_error_auth_reqed(self, auth_header, host, req, headers): + # Reset the retry counter once for each request. + if req is not self.retried_req: + self.retried_req = req + self.retried = 0 + return urllib2.HTTPBasicAuthHandler.http_error_auth_reqed( + self, auth_header, host, req, headers) + def getauthinfo(path): scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path) if not urlpath: @@ -615,7 +634,7 @@ ui.debug('http auth: user %s, password %s\n' % (user, passwd and '*' * len(passwd) or 'not set')) - handlers.extend((urllib2.HTTPBasicAuthHandler(passmgr), + handlers.extend((httpbasicauthhandler(passmgr), httpdigestauthhandler(passmgr))) handlers.extend([h(ui, passmgr) for h in handlerfuncs]) opener = urllib2.build_opener(*handlers)