Mercurial > public > mercurial-scm > hg
comparison mercurial/url.py @ 13424:08f9c587141f
url: merge BetterHTTPS with httpsconnection to get some proxy https validation
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Wed, 16 Feb 2011 04:36:36 +0100 |
parents | ebce5196b9db |
children | 66d65bccbf06 |
comparison
equal
deleted
inserted
replaced
13423:4e60dad2261f | 13424:08f9c587141f |
---|---|
540 return None | 540 return None |
541 return _('certificate is for %s') % certname | 541 return _('certificate is for %s') % certname |
542 return _('no commonName or subjectAltName found in certificate') | 542 return _('no commonName or subjectAltName found in certificate') |
543 | 543 |
544 if has_https: | 544 if has_https: |
545 class BetterHTTPS(httplib.HTTPSConnection): | 545 class httpsconnection(httplib.HTTPSConnection): |
546 send = keepalive.safesend | 546 response_class = keepalive.HTTPResponse |
547 # must be able to send big bundle as stream. | |
548 send = _gen_sendfile(keepalive.safesend) | |
549 getresponse = keepalive.wrapgetresponse(httplib.HTTPSConnection) | |
547 | 550 |
548 def connect(self): | 551 def connect(self): |
549 self.sock = _create_connection((self.host, self.port)) | 552 self.sock = _create_connection((self.host, self.port)) |
550 | 553 |
551 host = self.host | 554 host = self.host |
555 if self.realhostport: # use CONNECT proxy | |
556 something = _generic_proxytunnel(self) | |
557 host = self.realhostport.rsplit(':', 1)[0] | |
558 | |
552 cacerts = self.ui.config('web', 'cacerts') | 559 cacerts = self.ui.config('web', 'cacerts') |
553 hostfingerprint = self.ui.config('hostfingerprints', host) | 560 hostfingerprint = self.ui.config('hostfingerprints', host) |
554 | 561 |
555 if cacerts and not hostfingerprint: | 562 if cacerts and not hostfingerprint: |
556 self.sock = _ssl_wrap_socket(self.sock, self.key_file, | 563 self.sock = _ssl_wrap_socket(self.sock, self.key_file, |
590 'configured hostfingerprint') % host) | 597 'configured hostfingerprint') % host) |
591 self.ui.warn(_('warning: %s certificate not verified ' | 598 self.ui.warn(_('warning: %s certificate not verified ' |
592 '(check web.cacerts config setting)\n') % | 599 '(check web.cacerts config setting)\n') % |
593 host) | 600 host) |
594 | 601 |
595 class httpsconnection(BetterHTTPS): | |
596 response_class = keepalive.HTTPResponse | |
597 # must be able to send big bundle as stream. | |
598 send = _gen_sendfile(BetterHTTPS.send) | |
599 getresponse = keepalive.wrapgetresponse(httplib.HTTPSConnection) | |
600 | |
601 def connect(self): | |
602 if self.realhostport: # use CONNECT proxy | |
603 self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
604 self.sock.connect((self.host, self.port)) | |
605 if _generic_proxytunnel(self): | |
606 self.sock = _ssl_wrap_socket(self.sock, self.key_file, | |
607 self.cert_file) | |
608 else: | |
609 BetterHTTPS.connect(self) | |
610 | |
611 class httpshandler(keepalive.KeepAliveHandler, urllib2.HTTPSHandler): | 602 class httpshandler(keepalive.KeepAliveHandler, urllib2.HTTPSHandler): |
612 def __init__(self, ui): | 603 def __init__(self, ui): |
613 keepalive.KeepAliveHandler.__init__(self) | 604 keepalive.KeepAliveHandler.__init__(self) |
614 urllib2.HTTPSHandler.__init__(self) | 605 urllib2.HTTPSHandler.__init__(self) |
615 self.ui = ui | 606 self.ui = ui |