|
|
|
@ -397,6 +397,7 @@ class NoSSLError(SSLValidationError):
|
|
|
|
|
CustomHTTPSConnection = None
|
|
|
|
|
CustomHTTPSHandler = None
|
|
|
|
|
HTTPSClientAuthHandler = None
|
|
|
|
|
UnixHTTPSConnection = None
|
|
|
|
|
if hasattr(httplib, 'HTTPSConnection') and hasattr(urllib_request, 'HTTPSHandler'):
|
|
|
|
|
class CustomHTTPSConnection(httplib.HTTPSConnection):
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
@ -478,7 +479,6 @@ if hasattr(httplib, 'HTTPSConnection') and hasattr(urllib_request, 'HTTPSHandler
|
|
|
|
|
return UnixHTTPSConnection(self._unix_socket)(host, **kwargs)
|
|
|
|
|
return httplib.HTTPSConnection(host, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@contextmanager
|
|
|
|
|
def unix_socket_patch_httpconnection_connect():
|
|
|
|
|
'''Monkey patch ``httplib.HTTPConnection.connect`` to be ``UnixHTTPConnection.connect``
|
|
|
|
@ -490,7 +490,6 @@ def unix_socket_patch_httpconnection_connect():
|
|
|
|
|
yield
|
|
|
|
|
httplib.HTTPConnection.connect = _connect
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UnixHTTPSConnection(httplib.HTTPSConnection):
|
|
|
|
|
def __init__(self, unix_socket):
|
|
|
|
|
self._unix_socket = unix_socket
|
|
|
|
@ -499,6 +498,10 @@ class UnixHTTPSConnection(httplib.HTTPSConnection):
|
|
|
|
|
# This method exists simply to ensure we monkeypatch
|
|
|
|
|
# httplib.HTTPConnection.connect to call UnixHTTPConnection.connect
|
|
|
|
|
with unix_socket_patch_httpconnection_connect():
|
|
|
|
|
# Disable pylint check for the super() call. It complains about UnixHTTPSConnection
|
|
|
|
|
# being a NoneType because of the initial definition above, but it won't actually
|
|
|
|
|
# be a NoneType when this code runs
|
|
|
|
|
# pylint: disable=bad-super-call
|
|
|
|
|
super(UnixHTTPSConnection, self).connect()
|
|
|
|
|
|
|
|
|
|
def __call__(self, *args, **kwargs):
|
|
|
|
|