Catch occasional protocol errors in regular connect

Fixes #1843 and #1847
This commit is contained in:
Aldo Cortesi 2016-12-16 10:54:36 +13:00
parent 6b5673e849
commit 61e552553c

View File

@ -182,6 +182,17 @@ class HttpLayer(base.Layer):
try: try:
self.set_server((f.request.host, f.request.port)) self.set_server((f.request.host, f.request.port))
if f.response:
resp = f.response
else:
resp = http.make_connect_response(f.request.data.http_version)
self.send_response(resp)
if is_ok(resp.status_code):
layer = self.ctx.next_layer(self)
layer()
except ( except (
exceptions.ProtocolException, exceptions.NetlibException exceptions.ProtocolException, exceptions.NetlibException
) as e: ) as e:
@ -192,17 +203,6 @@ class HttpLayer(base.Layer):
self.channel.ask("error", f) self.channel.ask("error", f)
return False return False
if f.response:
resp = f.response
else:
resp = http.make_connect_response(f.request.data.http_version)
self.send_response(resp)
if is_ok(resp.status_code):
layer = self.ctx.next_layer(self)
layer()
return False return False
def handle_upstream_connect(self, f): def handle_upstream_connect(self, f):