https://github.com/python/cpython/commit/1fe89d324e6b96dc44a7bd593c428a90d1f39d55
commit: 1fe89d324e6b96dc44a7bd593c428a90d1f39d55
branch: main
author: Bénédikt Tran <[email protected]>
committer: picnixz <[email protected]>
date: 2025-10-05T16:51:16Z
summary:
gh-70765: fix an HTTP/0.9 flaky test post GH-139514 (#139610)
Fix a flaky test introduced in 13dc2fde8cec1e8aad04c7635b3da4ff3e3dcb00.
After a single HTTP/0.9 request, both client and server are expected to
close the connection on their side. In particular, if a client sends two
requests with the same connection, only the first one should be handled.
In the tests, it might happen that checking for the second request to be
ignored did not take into account that the server may have already closed
the connection. This flaky behavior was first observed on macOS CI workers
but could not be reproduced locally on a Linux machine.
files:
M Lib/test/test_httpservers.py
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
index 85d3a346439f6a..7da5e3a1957588 100644
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -391,12 +391,13 @@ def test_single_request(self):
res = self.sock.recv(1024)
self.assertEqual(res, b"OK: here is /foo.html\r\n")
- self.sock.send(b'GET /bar.html\r\n')
- res = self.sock.recv(1024)
- # The server will not parse more input as it closed the connection.
- # Note that the socket connection itself is still opened since the
- # client is responsible for also closing it on their side.
- self.assertEqual(res, b'')
+ # Ignore errors if the connection is already closed,
+ # as this is the expected behavior of HTTP/0.9.
+ with contextlib.suppress(OSError):
+ self.sock.send(b'GET /bar.html\r\n')
+ res = self.sock.recv(1024)
+ # The server should not process our request.
+ self.assertEqual(res, b'')
def certdata_file(*path):
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]