Mercurial > hg
comparison mercurial/url.py @ 11493:cc4e2a7ca23f
Merge with stable
author | Martin Geisler <mg@aragost.com> |
---|---|
date | Fri, 02 Jul 2010 11:30:57 +0200 |
parents | 2ec346160783 |
children | 7c9beccb0533 6c51a5056020 |
comparison
equal
deleted
inserted
replaced
11428:8b452fe4bf50 | 11493:cc4e2a7ca23f |
---|---|
540 | 540 |
541 conn = httpsconnection(host, port, keyfile, certfile, *args, **kwargs) | 541 conn = httpsconnection(host, port, keyfile, certfile, *args, **kwargs) |
542 conn.ui = self.ui | 542 conn.ui = self.ui |
543 return conn | 543 return conn |
544 | 544 |
545 # In python < 2.5 AbstractDigestAuthHandler raises a ValueError if | |
546 # it doesn't know about the auth type requested. This can happen if | |
547 # somebody is using BasicAuth and types a bad password. | |
548 class httpdigestauthhandler(urllib2.HTTPDigestAuthHandler): | 545 class httpdigestauthhandler(urllib2.HTTPDigestAuthHandler): |
546 def __init__(self, *args, **kwargs): | |
547 urllib2.HTTPDigestAuthHandler.__init__(self, *args, **kwargs) | |
548 self.retried_req = None | |
549 | |
550 def reset_retry_count(self): | |
551 # Python 2.6.5 will call this on 401 or 407 errors and thus loop | |
552 # forever. We disable reset_retry_count completely and reset in | |
553 # http_error_auth_reqed instead. | |
554 pass | |
555 | |
549 def http_error_auth_reqed(self, auth_header, host, req, headers): | 556 def http_error_auth_reqed(self, auth_header, host, req, headers): |
557 # Reset the retry counter once for each request. | |
558 if req is not self.retried_req: | |
559 self.retried_req = req | |
560 self.retried = 0 | |
561 # In python < 2.5 AbstractDigestAuthHandler raises a ValueError if | |
562 # it doesn't know about the auth type requested. This can happen if | |
563 # somebody is using BasicAuth and types a bad password. | |
550 try: | 564 try: |
551 return urllib2.HTTPDigestAuthHandler.http_error_auth_reqed( | 565 return urllib2.HTTPDigestAuthHandler.http_error_auth_reqed( |
552 self, auth_header, host, req, headers) | 566 self, auth_header, host, req, headers) |
553 except ValueError, inst: | 567 except ValueError, inst: |
554 arg = inst.args[0] | 568 arg = inst.args[0] |
555 if arg.startswith("AbstractDigestAuthHandler doesn't know "): | 569 if arg.startswith("AbstractDigestAuthHandler doesn't know "): |
556 return | 570 return |
557 raise | 571 raise |
558 | |
559 # Python 2.6.5 will keep resetting the retry count on redirects, for | |
560 # example when the server returns 401 on failing auth (like google code | |
561 # currently does). We stop the endless recursion by not resetting the | |
562 # count. | |
563 def reset_retry_count(self): | |
564 pass | |
565 | 572 |
566 def getauthinfo(path): | 573 def getauthinfo(path): |
567 scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path) | 574 scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path) |
568 if not urlpath: | 575 if not urlpath: |
569 urlpath = '/' | 576 urlpath = '/' |