-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-69282: test_httpservers hangs since Python 3.5 #9564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
6701a44
b8a9ad2
4bc01b5
b73cb8e
8bb91de
d49e89b
362554e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -320,7 +320,10 @@ class request_handler(BaseHTTPRequestHandler): | |
default_request_version = 'HTTP/1.1' | ||
|
||
def do_GET(self): | ||
# gh-69282: Tell the client we're not sending any content along | ||
# with the response code. | ||
self.send_response(HTTPStatus.OK) | ||
self.send_header('Content-Length', 0) | ||
self.end_headers() | ||
|
||
def do_ERROR(self): | ||
|
@@ -331,8 +334,15 @@ def test_get(self): | |
self.con.connect() | ||
|
||
with support.captured_stderr() as err: | ||
self.con.request('GET', '/') | ||
# gh-69282: HTTP/1.1 specifies that the socket connection is to | ||
# remain open, this, on certain systems, causes Python to deadlock | ||
# waiting for the socket to close. | ||
# To combat this, we send the test server the "Connection" header | ||
# with "close" for the value forcing the server and client to | ||
# terminate the socket allowing the test to resume. | ||
self.con.request('GET', '/', headers={'Connection': 'close'}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The explanation seems vague. I would explain it as: “Connection: close” causes the server to set its “close_connection” flag. If the client did not also shut down the connection below, this flag would avoid a deadlock between the server waiting for a second request on the connection, and the main thread shutting the server down. |
||
self.con.getresponse() | ||
self.con.close() | ||
|
||
self.assertTrue( | ||
err.getvalue().endswith('"GET / HTTP/1.1" 200 -\n')) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Nitpick) It’s not really documented, and seems to work regardless, but I assume the header field value should be a string '0' not an integer