diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2015-05-05 10:47:02 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2015-05-05 10:47:02 +1200 |
commit | f2bc58cdd2f2b9b0025a88c0faccf55e10b29353 (patch) | |
tree | 9353f4b78f4bf8ec1e6b4169155da084a2c05ea9 /test/test_http.py | |
parent | 08b2e2a6a98fd175e1b49d62dffde34e91c77b1c (diff) | |
download | mitmproxy-f2bc58cdd2f2b9b0025a88c0faccf55e10b29353.tar.gz mitmproxy-f2bc58cdd2f2b9b0025a88c0faccf55e10b29353.tar.bz2 mitmproxy-f2bc58cdd2f2b9b0025a88c0faccf55e10b29353.zip |
Add tcp.Reader.safe_read, use it in socks and websockets
safe_read is guaranteed to raise or return a byte string of the
requested length. It's particularly useful for implementing binary
protocols.
Diffstat (limited to 'test/test_http.py')
-rw-r--r-- | test/test_http.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/test/test_http.py b/test/test_http.py index f1a31b93..63b39f08 100644 --- a/test/test_http.py +++ b/test/test_http.py @@ -91,7 +91,7 @@ def test_read_http_body_request(): def test_read_http_body_response(): h = odict.ODictCaseless() - s = cStringIO.StringIO("testing") + s = tcp.Reader(cStringIO.StringIO("testing")) assert http.read_http_body(s, h, None, "GET", 200, False) == "testing" @@ -135,11 +135,11 @@ def test_read_http_body(): # test no content length: limit > actual content h = odict.ODictCaseless() - s = cStringIO.StringIO("testing") + s = tcp.Reader(cStringIO.StringIO("testing")) assert len(http.read_http_body(s, h, 100, "GET", 200, False)) == 7 # test no content length: limit < actual content - s = cStringIO.StringIO("testing") + s = tcp.Reader(cStringIO.StringIO("testing")) tutils.raises( http.HttpError, http.read_http_body, @@ -149,7 +149,7 @@ def test_read_http_body(): # test chunked h = odict.ODictCaseless() h["transfer-encoding"] = ["chunked"] - s = cStringIO.StringIO("5\r\naaaaa\r\n0\r\n\r\n") + s = tcp.Reader(cStringIO.StringIO("5\r\naaaaa\r\n0\r\n\r\n")) assert http.read_http_body(s, h, 100, "GET", 200, False) == "aaaaa" |