aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_protocol_http.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/test_protocol_http.py b/test/test_protocol_http.py
index 4158adda..8c843d73 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.content
+
+
+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()