Mercurial > public > mercurial-scm > hg
comparison mercurial/url.py @ 25414:f7ccbc2776b7
https: do not inherit httplib.HTTPSConnection that creates unused SSLContext
HTTPSConnection of Python 2.7.9 creates SSLContext in __init__, which involves
a password prompt for decrypting the private key. This means the password was
asked twice, one for unused SSLContext, and next for our ssl function.
Because our httpsconnection replaces connect() method at all, we can simply
drop httplib.HTTPSConnection. Instead, class and instance attributes are copied
from it.
HTTPSConnection of Python 2.7.8 and 2.6.9 seem to have no such problem.
https://hg.python.org/cpython/file/v2.7.9/Lib/httplib.py#l1183
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 07 May 2015 17:02:20 +0900 |
parents | 6358391453f3 |
children | 21b536f01eda |
comparison
equal
deleted
inserted
replaced
25413:4d705f6a3c35 | 25414:f7ccbc2776b7 |
---|---|
316 def _start_transaction(self, h, req): | 316 def _start_transaction(self, h, req): |
317 _generic_start_transaction(self, h, req) | 317 _generic_start_transaction(self, h, req) |
318 return keepalive.HTTPHandler._start_transaction(self, h, req) | 318 return keepalive.HTTPHandler._start_transaction(self, h, req) |
319 | 319 |
320 if has_https: | 320 if has_https: |
321 class httpsconnection(httplib.HTTPSConnection): | 321 class httpsconnection(httplib.HTTPConnection): |
322 response_class = keepalive.HTTPResponse | 322 response_class = keepalive.HTTPResponse |
323 default_port = httplib.HTTPS_PORT | |
323 # must be able to send big bundle as stream. | 324 # must be able to send big bundle as stream. |
324 send = _gen_sendfile(keepalive.safesend) | 325 send = _gen_sendfile(keepalive.safesend) |
325 getresponse = keepalive.wrapgetresponse(httplib.HTTPSConnection) | 326 getresponse = keepalive.wrapgetresponse(httplib.HTTPConnection) |
327 | |
328 def __init__(self, host, port=None, key_file=None, cert_file=None, | |
329 *args, **kwargs): | |
330 httplib.HTTPConnection.__init__(self, host, port, *args, **kwargs) | |
331 self.key_file = key_file | |
332 self.cert_file = cert_file | |
326 | 333 |
327 def connect(self): | 334 def connect(self): |
328 self.sock = _create_connection((self.host, self.port)) | 335 self.sock = _create_connection((self.host, self.port)) |
329 | 336 |
330 host = self.host | 337 host = self.host |