aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_server.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2014-09-06 13:30:00 +0200
committerMaximilian Hils <git@maximilianhils.com>2014-09-06 13:30:00 +0200
commitdf129736c3a621847f7916d40edd909fe9fb0b8e (patch)
tree225d0b9fe18c54ed21fa3eedeaa9eb76a4a43af5 /test/test_server.py
parent3c65510ef54c5773c22cd439488ae21dac95ee74 (diff)
downloadmitmproxy-df129736c3a621847f7916d40edd909fe9fb0b8e.tar.gz
mitmproxy-df129736c3a621847f7916d40edd909fe9fb0b8e.tar.bz2
mitmproxy-df129736c3a621847f7916d40edd909fe9fb0b8e.zip
test streaming
Diffstat (limited to 'test/test_server.py')
-rw-r--r--test/test_server.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/test/test_server.py b/test/test_server.py
index 24d0ca5c..3906cb8e 100644
--- a/test/test_server.py
+++ b/test/test_server.py
@@ -142,11 +142,22 @@ class TestHTTP(tservers.HTTPProxTest, CommonMixin, AppMixin):
connection.connect(("127.0.0.1", self.proxy.port))
spec = '301:h"Transfer-Encoding"="chunked":r:b"0\\r\\n\\r\\n"'
connection.send("GET http://localhost:%d/p/%s HTTP/1.1\r\n"%(self.server.port, spec))
- connection.send("\r\n");
+ connection.send("\r\n")
resp = connection.recv(50000)
connection.close()
assert "content-length" in resp.lower()
+ def test_stream(self):
+ self.master.set_stream_large_bodies(1024 * 2)
+
+ self.pathod("200:b@1k")
+ assert not self.master.state.view[-1].response.stream
+ assert len(self.master.state.view[-1].response.content) == 1024 * 1
+
+ self.pathod("200:b@3k")
+ assert self.master.state.view[-1].response.stream
+ assert self.master.state.view[-1].response.content == CONTENT_MISSING
+ self.master.set_stream_large_bodies(None)
class TestHTTPAuth(tservers.HTTPProxTest):
authenticator = http_auth.BasicProxyAuth(http_auth.PassManSingleUser("test", "test"), "realm")
@@ -267,7 +278,7 @@ class TestProxy(tservers.HTTPProxTest):
# call pathod server, wait a second to complete the request
connection.send("GET http://localhost:%d/p/304:b@1k HTTP/1.1\r\n"%self.server.port)
time.sleep(1)
- connection.send("\r\n");
+ connection.send("\r\n")
connection.recv(50000)
connection.close()
@@ -294,10 +305,10 @@ class TestProxy(tservers.HTTPProxTest):
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
connection.connect(("localhost", self.proxy.port))
connection.send("GET http://localhost:%d/p/304:b@1k HTTP/1.1\r\n"%self.server.port)
- connection.send("\r\n");
+ connection.send("\r\n")
connection.recv(5000)
connection.send("GET http://localhost:%d/p/304:b@1k HTTP/1.1\r\n"%self.server.port)
- connection.send("\r\n");
+ connection.send("\r\n")
connection.recv(5000)
connection.close()