Catch occasional protocol errors in regular connect
diff --git a/mitmproxy/proxy/protocol/http.py b/mitmproxy/proxy/protocol/http.py
index f3e0f514cd..50d64e1743 100644
--- a/mitmproxy/proxy/protocol/http.py
+++ b/mitmproxy/proxy/protocol/http.py
@@ -182,6 +182,17 @@ def handle_regular_connect(self, f):
 
         try:
             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 (
             exceptions.ProtocolException, exceptions.NetlibException
         ) as e:
@@ -192,17 +203,6 @@ def handle_regular_connect(self, f):
             self.channel.ask("error", f)
             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
 
     def handle_upstream_connect(self, f):

Fixes #1843 and #1847