From 6661770d4eee3eab3305793613586f3684c24ae9 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 28 Sep 2015 10:59:10 +0200 Subject: handle Expect: 100-continue header, fix #770 --- test/test_protocol_http.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'test/test_protocol_http.py') 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 -- cgit v1.2.3