Skip to content

Commit a660e75

Browse files
dbungertogayot
andcommitted
testutils: fix test flake on HEAD request
Flakiness may be observed when running the unit tests. The symptom of that looks like: requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine('Hello world!HTTP/1.1 200 OK\r\n')) We believe that, with the correct send and recv timing, the "Hello world!" body from a HEAD request will be left unread in the reused socket, resulting in an invalid read for the next request along. Co-authored-by: Olivier Gayot <[email protected]>
1 parent 31bdd06 commit a660e75

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

requests_unixsocket/testutils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ def __call__(self, environ, start_response):
5151
('X-Requested-Query-String', environ['QUERY_STRING']),
5252
('X-Requested-Path', environ['PATH_INFO'])]
5353
body_bytes = b'Hello world!'
54+
if environ['REQUEST_METHOD'] == 'HEAD':
55+
body_bytes = b''
5456
start_response(status_text, response_headers)
5557
logger.debug(
5658
'WSGIApp.__call__: Responding with '

0 commit comments

Comments
 (0)