diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-06-30 15:59:42 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-06-30 15:59:42 +1200 |
commit | f070e4523aebd383f6424a020c93f4065aaa673c (patch) | |
tree | 10e8cc37d987d23e52344994264a70cbed377f91 /test | |
parent | 16e87a81acf2f6992a47d54b6f2cad61c8b8ff2b (diff) | |
download | mitmproxy-f070e4523aebd383f6424a020c93f4065aaa673c.tar.gz mitmproxy-f070e4523aebd383f6424a020c93f4065aaa673c.tar.bz2 mitmproxy-f070e4523aebd383f6424a020c93f4065aaa673c.zip |
Handle invalid data more gracefully.
Fixes #47
Diffstat (limited to 'test')
-rw-r--r-- | test/test_server.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/test/test_server.py b/test/test_server.py index 8878cf32..e4a62fa5 100644 --- a/test/test_server.py +++ b/test/test_server.py @@ -1,6 +1,7 @@ import urllib, urllib2, unittest import time import libpathod.test, requests +from netlib import tcp, http import tutils """ @@ -21,7 +22,19 @@ class SanityMixin: class TestHTTP(tutils.HTTPProxTest, SanityMixin): - pass + def test_invalid_http(self): + t = tcp.TCPClient("127.0.0.1", self.proxy.port) + t.connect() + t.wfile.write("invalid\n\n") + t.wfile.flush() + assert "Bad Request" in t.rfile.readline() + + def test_invalid_connect(self): + t = tcp.TCPClient("127.0.0.1", self.proxy.port) + t.connect() + t.wfile.write("CONNECT invalid\n\n") + t.wfile.flush() + assert "Bad Request" in t.rfile.readline() class TestHTTPS(tutils.HTTPProxTest, SanityMixin): |