Details
Details
- Reviewers
 durin42 - Group Reviewers
 hg-reviewers - Commits
 - rHG8549ca7fcde1: py3: handle keyword arguments correctly in httpconnection.py
 
Diff Detail
Diff Detail
- Repository
 - rHG Mercurial
 - Lint
 Lint Skipped - Unit
 Unit Tests Skipped 
( )
| durin42 | 
| hg-reviewers | 
| Lint Skipped | 
| Unit Tests Skipped | 
| # httplib always uses the given host/port as the socket connect | # httplib always uses the given host/port as the socket connect | ||||
| # target, and then allows full URIs in the request path, which it | # target, and then allows full URIs in the request path, which it | ||||
| # then observes and treats as a signal to do proxying instead. | # then observes and treats as a signal to do proxying instead. | ||||
| def http_open(self, req): | def http_open(self, req): | ||||
| if urllibcompat.getfullurl(req).startswith('https'): | if urllibcompat.getfullurl(req).startswith('https'): | ||||
| return self.https_open(req) | return self.https_open(req) | ||||
| def makehttpcon(*args, **kwargs): | def makehttpcon(*args, **kwargs): | ||||
| k2 = dict(kwargs) | k2 = dict(kwargs) | ||||
| k2['use_ssl'] = False | k2[r'use_ssl'] = False | ||||
| return HTTPConnection(*args, **k2) | return HTTPConnection(*args, **k2) | ||||
| return self.do_open(makehttpcon, req, False) | return self.do_open(makehttpcon, req, False) | ||||
| def https_open(self, req): | def https_open(self, req): | ||||
| # urllibcompat.getfullurl(req) does not contain credentials and we may | # urllibcompat.getfullurl(req) does not contain credentials and we may | ||||
| # need them to match the certificates. | # need them to match the certificates. | ||||
| url = urllibcompat.getfullurl(req) | url = urllibcompat.getfullurl(req) | ||||
| user, password = self.pwmgr.find_stored_password(url) | user, password = self.pwmgr.find_stored_password(url) | ||||
| # let host port take precedence | # let host port take precedence | ||||
| if ':' in host and '[' not in host or ']:' in host: | if ':' in host and '[' not in host or ']:' in host: | ||||
| host, port = host.rsplit(':', 1) | host, port = host.rsplit(':', 1) | ||||
| port = int(port) | port = int(port) | ||||
| if '[' in host: | if '[' in host: | ||||
| host = host[1:-1] | host = host[1:-1] | ||||
| kwargs['keyfile'] = keyfile | kwargs[r'keyfile'] = keyfile | ||||
| kwargs['certfile'] = certfile | kwargs[r'certfile'] = certfile | ||||
| con = HTTPConnection(host, port, use_ssl=True, | con = HTTPConnection(host, port, use_ssl=True, | ||||
| ssl_wrap_socket=sslutil.wrapsocket, | ssl_wrap_socket=sslutil.wrapsocket, | ||||
| ssl_validator=sslutil.validatesocket, | ssl_validator=sslutil.validatesocket, | ||||
| ui=self.ui, | ui=self.ui, | ||||
| **kwargs) | **kwargs) | ||||
| return con | return con | ||||