This commit is contained in:
coletdjnz 2024-04-04 19:34:28 +13:00
parent 41add1d7af
commit 6c3140a8c1
No known key found for this signature in database
GPG Key ID: 91984263BB39894A

View File

@ -156,9 +156,8 @@ def do_CONNECT(self):
'path': self.path,
'proxy': ':'.join(str(y) for y in self.connection.getsockname()),
}
request = self.request
self.request_handler(self.request, self.client_address, self.server, proxy_info=proxy_info)
self.server.close_request(request)
self.server.close_request(self.request)
class HTTPSConnectProxyHandler(HTTPConnectProxyHandler):
@ -167,8 +166,13 @@ def __init__(self, request, *args, **kwargs):
sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
sslctx.load_cert_chain(certfn, None)
request = sslctx.wrap_socket(request, server_side=True)
self._original_request = request
super().__init__(request, *args, **kwargs)
def do_CONNECT(self):
super().do_CONNECT()
self.server.close_request(self._original_request)
@contextlib.contextmanager
def proxy_server(proxy_server_class, request_handler, bind_ip=None, **proxy_server_kwargs):