##// END OF EJS Templates
http basic auth: reset redirect counter on new requests (issue2255)...
Wagner Bruna -
r11844:6c51a505 stable
parent child Browse files
Show More
@@ -570,6 +570,25 b' class httpdigestauthhandler(urllib2.HTTP'
570 return
570 return
571 raise
571 raise
572
572
573 class httpbasicauthhandler(urllib2.HTTPBasicAuthHandler):
574 def __init__(self, *args, **kwargs):
575 urllib2.HTTPBasicAuthHandler.__init__(self, *args, **kwargs)
576 self.retried_req = None
577
578 def reset_retry_count(self):
579 # Python 2.6.5 will call this on 401 or 407 errors and thus loop
580 # forever. We disable reset_retry_count completely and reset in
581 # http_error_auth_reqed instead.
582 pass
583
584 def http_error_auth_reqed(self, auth_header, host, req, headers):
585 # Reset the retry counter once for each request.
586 if req is not self.retried_req:
587 self.retried_req = req
588 self.retried = 0
589 return urllib2.HTTPBasicAuthHandler.http_error_auth_reqed(
590 self, auth_header, host, req, headers)
591
573 def getauthinfo(path):
592 def getauthinfo(path):
574 scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path)
593 scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path)
575 if not urlpath:
594 if not urlpath:
@@ -615,7 +634,7 b' def opener(ui, authinfo=None):'
615 ui.debug('http auth: user %s, password %s\n' %
634 ui.debug('http auth: user %s, password %s\n' %
616 (user, passwd and '*' * len(passwd) or 'not set'))
635 (user, passwd and '*' * len(passwd) or 'not set'))
617
636
618 handlers.extend((urllib2.HTTPBasicAuthHandler(passmgr),
637 handlers.extend((httpbasicauthhandler(passmgr),
619 httpdigestauthhandler(passmgr)))
638 httpdigestauthhandler(passmgr)))
620 handlers.extend([h(ui, passmgr) for h in handlerfuncs])
639 handlers.extend([h(ui, passmgr) for h in handlerfuncs])
621 opener = urllib2.build_opener(*handlers)
640 opener = urllib2.build_opener(*handlers)
General Comments 0
You need to be logged in to leave comments. Login now