From df129736c3a621847f7916d40edd909fe9fb0b8e Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Sat, 6 Sep 2014 13:30:00 +0200 Subject: [PATCH] test streaming --- test/test_server.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/test/test_server.py b/test/test_server.py index 24d0ca5c8..3906cb8ef 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()