Show More
@@ -292,7 +292,7 b' class HTTPConnection(object):' | |||||
292 | def __init__(self, host, port=None, use_ssl=None, ssl_validator=None, |
|
292 | def __init__(self, host, port=None, use_ssl=None, ssl_validator=None, | |
293 | timeout=TIMEOUT_DEFAULT, |
|
293 | timeout=TIMEOUT_DEFAULT, | |
294 | continue_timeout=TIMEOUT_ASSUME_CONTINUE, |
|
294 | continue_timeout=TIMEOUT_ASSUME_CONTINUE, | |
295 | proxy_hostport=None, **ssl_opts): |
|
295 | proxy_hostport=None, ssl_wrap_socket=None, **ssl_opts): | |
296 | """Create a new HTTPConnection. |
|
296 | """Create a new HTTPConnection. | |
297 |
|
297 | |||
298 | Args: |
|
298 | Args: | |
@@ -307,12 +307,23 b' class HTTPConnection(object):' | |||||
307 | "100 Continue" response. Default is TIMEOUT_ASSUME_CONTINUE. |
|
307 | "100 Continue" response. Default is TIMEOUT_ASSUME_CONTINUE. | |
308 | proxy_hostport: Optional. Tuple of (host, port) to use as an http |
|
308 | proxy_hostport: Optional. Tuple of (host, port) to use as an http | |
309 | proxy for the connection. Default is to not use a proxy. |
|
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 | if port is None and host.count(':') == 1 or ']:' in host: |
|
318 | if port is None and host.count(':') == 1 or ']:' in host: | |
312 | host, port = host.rsplit(':', 1) |
|
319 | host, port = host.rsplit(':', 1) | |
313 | port = int(port) |
|
320 | port = int(port) | |
314 | if '[' in host: |
|
321 | if '[' in host: | |
315 | host = host[1:-1] |
|
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 | if use_ssl is None and port is None: |
|
327 | if use_ssl is None and port is None: | |
317 | use_ssl = False |
|
328 | use_ssl = False | |
318 | port = 80 |
|
329 | port = 80 | |
@@ -387,7 +398,7 b' class HTTPConnection(object):' | |||||
387 | sock.setblocking(1) |
|
398 | sock.setblocking(1) | |
388 | logger.debug('wrapping socket for ssl with options %r', |
|
399 | logger.debug('wrapping socket for ssl with options %r', | |
389 | self.ssl_opts) |
|
400 | self.ssl_opts) | |
390 |
sock = s |
|
401 | sock = self._ssl_wrap_socket(sock, **self.ssl_opts) | |
391 | if self._ssl_validator: |
|
402 | if self._ssl_validator: | |
392 | self._ssl_validator(sock) |
|
403 | self._ssl_validator(sock) | |
393 | sock.setblocking(0) |
|
404 | sock.setblocking(0) |
General Comments 0
You need to be logged in to leave comments.
Login now