diff options
author | Maximilian Hils <git@maximilianhils.com> | 2015-09-28 10:59:10 +0200 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2015-09-28 10:59:10 +0200 |
commit | 6661770d4eee3eab3305793613586f3684c24ae9 (patch) | |
tree | 2d387b0b2407bb61c9688c5ff7844f16c4cf3d5c /test | |
parent | a978c6b9cee134d01f84216f3fbcf1ae9303d965 (diff) | |
download | mitmproxy-6661770d4eee3eab3305793613586f3684c24ae9.tar.gz mitmproxy-6661770d4eee3eab3305793613586f3684c24ae9.tar.bz2 mitmproxy-6661770d4eee3eab3305793613586f3684c24ae9.zip |
handle Expect: 100-continue header, fix #770
Diffstat (limited to 'test')
-rw-r--r-- | test/test_protocol_http.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/test_protocol_http.py b/test/test_protocol_http.py index 5ddb5b5b..5943b57f 100644 --- a/test/test_protocol_http.py +++ b/test/test_protocol_http.py @@ -1,7 +1,9 @@ +import socket from io import BytesIO from netlib.exceptions import HttpSyntaxException from netlib.http import http1 +from netlib.tcp import TCPClient from netlib.tutils import treq, raises import tutils import tservers @@ -54,3 +56,29 @@ class TestInvalidRequests(tservers.HTTPProxTest): r = p.request("get:/p/200") assert r.status_code == 400 assert "Invalid HTTP request form" in r.body + + +class TestExpectHeader(tservers.HTTPProxTest): + def test_simple(self): + client = TCPClient(("127.0.0.1", self.proxy.port)) + client.connect() + + # call pathod server, wait a second to complete the request + client.wfile.write( + b"POST http://localhost:%d/p/200 HTTP/1.1\r\n" + b"Expect: 100-continue\r\n" + b"Content-Length: 16\r\n" + b"\r\n" % self.server.port + ) + client.wfile.flush() + + assert client.rfile.readline() == "HTTP/1.1 100 Continue\r\n" + assert client.rfile.readline() == "\r\n" + + client.wfile.write(b"0123456789abcdef\r\n") + client.wfile.flush() + + resp = http1.read_response(client.rfile, treq()) + assert resp.status_code == 200 + + client.finish()
\ No newline at end of file |