Permalink
Browse files

Test replay corner cases. Fix discovered bugs.

  • Loading branch information...
1 parent aab4507 commit 79af9e89c44597e58e6db0486a54e133e9def704 @cortesi cortesi committed Jul 8, 2012
Showing with 16 additions and 5 deletions.
  1. +2 −1 .gitignore
  2. +2 −4 libmproxy/proxy.py
  3. +12 −0 test/test_server.py
View
3 .gitignore
@@ -8,5 +8,6 @@ MANIFEST
*.swo
mitmproxyc
mitmdumpc
-netlib
.coverage
+netlib
+libpathod
View
6 libmproxy/proxy.py
@@ -67,11 +67,9 @@ def run(self):
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):
View
12 test/test_server.py
@@ -30,6 +30,18 @@ def test_replay(self):
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):

0 comments on commit 79af9e8

Please sign in to comment.