diff options
-rw-r--r-- | mitmproxy/exceptions.py | 4 | ||||
-rw-r--r-- | mitmproxy/protocol/http.py | 11 | ||||
-rw-r--r-- | mitmproxy/proxy/server.py | 2 |
3 files changed, 11 insertions, 6 deletions
diff --git a/mitmproxy/exceptions.py b/mitmproxy/exceptions.py index c4797e21..6873215c 100644 --- a/mitmproxy/exceptions.py +++ b/mitmproxy/exceptions.py @@ -27,6 +27,10 @@ class Kill(ProxyException): class ProtocolException(ProxyException): + """ + ProtocolExceptions are caused by invalid user input, unavailable network resources, + or other events that are outside of our influence. + """ pass diff --git a/mitmproxy/protocol/http.py b/mitmproxy/protocol/http.py index 1418d6e9..1632e66f 100644 --- a/mitmproxy/protocol/http.py +++ b/mitmproxy/protocol/http.py @@ -153,12 +153,13 @@ class HttpLayer(base.Layer): # We optimistically guess there might be an HTTP client on the # other end self.send_error_response(400, repr(e)) - self.log( - "request", - "warn", - "HTTP protocol error in client request: %s" % e + six.reraise( + exceptions.ProtocolException, + exceptions.ProtocolException( + "HTTP protocol error in client request: {}".format(e) + ), + sys.exc_info()[2] ) - return self.log("request", "debug", [repr(request)]) diff --git a/mitmproxy/proxy/server.py b/mitmproxy/proxy/server.py index 4fd5755a..c5fd5f9e 100644 --- a/mitmproxy/proxy/server.py +++ b/mitmproxy/proxy/server.py @@ -132,7 +132,7 @@ class ConnectionHandler(object): self.log(str(e), "warn") self.log("Invalid certificate, closing connection. Pass --insecure to disable validation.", "warn") else: - self.log(repr(e), "warn") + self.log(str(e), "warn") self.log(traceback.format_exc(), "debug") # If an error propagates to the topmost level, |