File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import cgi
2+ from io import DEFAULT_BUFFER_SIZE
23import logging
34import socket
45import sys
1314
1415log = logging .getLogger (__name__ )
1516
17+ TARGET_CL = DEFAULT_BUFFER_SIZE * 2
18+
1619
1720@pytest .mark .usefixtures ("serve" )
1821def test_request_reading (serve ):
@@ -64,7 +67,7 @@ def test_interrupted_request(serve):
6467
6568
6669def _test_app_req_interrupt (env , sr ):
67- target_cl = 100000
70+ target_cl = TARGET_CL
6871 try :
6972 req = Request (env )
7073 cl = req .content_length
@@ -94,7 +97,7 @@ def _req_int_cgi(req):
9497def _req_int_readline (req ):
9598 try :
9699 assert req .body_file .readline () == b"a=b\n "
97- except OSError :
100+ except OSError as exc :
98101 # too early to detect disconnect
99102 raise AssertionError ("False disconnect alert" )
100103 req .body_file .readline ()
@@ -126,7 +129,7 @@ def _send_interrupted_req(server, path="/"):
126129_interrupted_req = (
127130 "POST %s HTTP/1.0\r \n "
128131 "content-type: application/x-www-form-urlencoded\r \n "
129- "content-length: 100000 \r \n "
132+ f "content-length: { TARGET_CL } \r \n "
130133 "\r \n "
131134)
132- _interrupted_req += "a=b\n z=" + "x" * 10000
135+ _interrupted_req += "a=b\n z=" + "x" * DEFAULT_BUFFER_SIZE
You can’t perform that action at this time.
0 commit comments