Allow http_connect to create a response for CONNECT request so that connection to server be postponed in upstream mode.

This commit is contained in:
Biping Meng 2017-07-26 18:19:38 +08:00
parent d409a6c09a
commit 1004460ba6

View File

@ -217,16 +217,17 @@ class HttpLayer(base.Layer):
return False return False
def handle_upstream_connect(self, f): def handle_upstream_connect(self, f):
self.establish_server_connection( if not f.response:
f.request.host, self.establish_server_connection(
f.request.port, f.request.host,
f.request.scheme f.request.port,
) f.request.scheme
self.send_request(f.request) )
f.response = self.read_response_headers() self.send_request(f.request)
f.response.data.content = b"".join( f.response = self.read_response_headers()
self.read_response_body(f.request, f.response) f.response.data.content = b"".join(
) self.read_response_body(f.request, f.response)
)
self.send_response(f.response) self.send_response(f.response)
if is_ok(f.response.status_code): if is_ok(f.response.status_code):
layer = UpstreamConnectLayer(self, f.request) layer = UpstreamConnectLayer(self, f.request)