diff --git a/.gitignore b/.gitignore index b88b179bd..f268eff1c 100644 --- a/.gitignore +++ b/.gitignore @@ -8,5 +8,6 @@ MANIFEST *.swo mitmproxyc mitmdumpc -netlib .coverage +netlib +libpathod diff --git a/libmproxy/proxy.py b/libmproxy/proxy.py index bc7051d45..e7b2c409a 100644 --- a/libmproxy/proxy.py +++ b/libmproxy/proxy.py @@ -67,11 +67,9 @@ class RequestReplayThread(threading.Thread): self.flow.request, httpversion, code, msg, headers, content, server.cert ) response._send(self.masterq) - except (ProxyError, http.HttpError), v: - err = flow.Error(self.flow.request, v.msg) + except (ProxyError, http.HttpError, tcp.NetLibError), v: + err = flow.Error(self.flow.request, str(v)) err._send(self.masterq) - except tcp.NetLibError, v: - raise ProxyError(502, v) class ServerConnection(tcp.TCPClient): diff --git a/test/test_server.py b/test/test_server.py index a500d81cd..72be976fd 100644 --- a/test/test_server.py +++ b/test/test_server.py @@ -30,6 +30,18 @@ class SanityMixin: rt.join() assert l.response.code == 305 + # Disconnect error + l.request.path = "/p/305:d0" + rt = self.master.replay_request(l) + rt.join() + assert l.error + + # Port error + l.request.port = 1 + rt = self.master.replay_request(l) + rt.join() + assert l.error + class TestHTTP(tutils.HTTPProxTest, SanityMixin): def test_invalid_http(self):