##// END OF EJS Templates
httpclient: import 4bb625347d4a to provide SSL wrapper injection...
Augie Fackler -
r19807:c48df403 default
parent child Browse files
Show More
@@ -292,7 +292,7 class HTTPConnection(object):
292 292 def __init__(self, host, port=None, use_ssl=None, ssl_validator=None,
293 293 timeout=TIMEOUT_DEFAULT,
294 294 continue_timeout=TIMEOUT_ASSUME_CONTINUE,
295 proxy_hostport=None, **ssl_opts):
295 proxy_hostport=None, ssl_wrap_socket=None, **ssl_opts):
296 296 """Create a new HTTPConnection.
297 297
298 298 Args:
@@ -307,12 +307,23 class HTTPConnection(object):
307 307 "100 Continue" response. Default is TIMEOUT_ASSUME_CONTINUE.
308 308 proxy_hostport: Optional. Tuple of (host, port) to use as an http
309 309 proxy for the connection. Default is to not use a proxy.
310 ssl_wrap_socket: Optional function to use for wrapping
311 sockets. If unspecified, the one from the ssl module will
312 be used if available, or something that's compatible with
313 it if on a Python older than 2.6.
314
315 Any extra keyword arguments to this function will be provided
316 to the ssl_wrap_socket method. If no ssl
310 317 """
311 318 if port is None and host.count(':') == 1 or ']:' in host:
312 319 host, port = host.rsplit(':', 1)
313 320 port = int(port)
314 321 if '[' in host:
315 322 host = host[1:-1]
323 if ssl_wrap_socket is not None:
324 self._ssl_wrap_socket = ssl_wrap_socket
325 else:
326 self._ssl_wrap_socket = socketutil.wrap_socket
316 327 if use_ssl is None and port is None:
317 328 use_ssl = False
318 329 port = 80
@@ -387,7 +398,7 class HTTPConnection(object):
387 398 sock.setblocking(1)
388 399 logger.debug('wrapping socket for ssl with options %r',
389 400 self.ssl_opts)
390 sock = socketutil.wrap_socket(sock, **self.ssl_opts)
401 sock = self._ssl_wrap_socket(sock, **self.ssl_opts)
391 402 if self._ssl_validator:
392 403 self._ssl_validator(sock)
393 404 sock.setblocking(0)
General Comments 0
You need to be logged in to leave comments. Login now