aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/proxy
diff options
context:
space:
mode:
authorcs <cs010@hotmail.com>2019-08-09 14:19:10 +0800
committercs <cs010@hotmail.com>2019-08-09 14:19:10 +0800
commit0d042c6d8eb89691b7f731ccfd3d4bbaa27e3d48 (patch)
treefb4977ea9ef8598acfecd678260c9ba2eb91509b /mitmproxy/proxy
parent8353f4a55afeec9d30727d91d642e8b8af4040f8 (diff)
downloadmitmproxy-0d042c6d8eb89691b7f731ccfd3d4bbaa27e3d48.tar.gz
mitmproxy-0d042c6d8eb89691b7f731ccfd3d4bbaa27e3d48.tar.bz2
mitmproxy-0d042c6d8eb89691b7f731ccfd3d4bbaa27e3d48.zip
fix duplicate error response
Diffstat (limited to 'mitmproxy/proxy')
-rw-r--r--mitmproxy/proxy/protocol/http.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/mitmproxy/proxy/protocol/http.py b/mitmproxy/proxy/protocol/http.py
index 2ae656b3..4c20617b 100644
--- a/mitmproxy/proxy/protocol/http.py
+++ b/mitmproxy/proxy/protocol/http.py
@@ -263,7 +263,7 @@ class HttpLayer(base.Layer):
else:
msg = "Unexpected CONNECT request."
self.send_error_response(400, msg)
- raise exceptions.ProtocolException(msg)
+ return False
validate_request_form(self.mode, request)
self.channel.ask("requestheaders", f)
@@ -289,9 +289,12 @@ class HttpLayer(base.Layer):
f.request = None
f.error = flow.Error(str(e))
self.channel.ask("error", f)
- raise exceptions.ProtocolException(
- "HTTP protocol error in client request: {}".format(e)
- ) from e
+ self.log(
+ "request",
+ "warn",
+ ["HTTP protocol error in client request: {}".format(e)]
+ )
+ return False
self.log("request", "debug", [repr(request)])
@@ -448,8 +451,8 @@ class HttpLayer(base.Layer):
return False # should never be reached
except (exceptions.ProtocolException, exceptions.NetlibException) as e:
- self.send_error_response(502, repr(e))
if not f.response:
+ self.send_error_response(502, repr(e))
f.error = flow.Error(str(e))
self.channel.ask("error", f)
return False