8000 Moved the 'Content-Length' header to the server's response. · python/cpython@b8a9ad2 · GitHub
[go: up one dir, main page]

Skip to content

Commit b8a9ad2

Browse files
committed
Moved the 'Content-Length' header to the server's response.
Added 'self.con.close()' after 'self.con.getresponse()' to close the socket connection. Kept the 'Connection' header in the request to signal our intent to terminate the socket.
1 parent 6701a44 commit b8a9ad2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Lib/test/test_httpservers.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,10 @@ class request_handler(BaseHTTPRequestHandler):
294294
default_request_version = 'HTTP/1.1'
295295

296296
def do_GET(self):
297+
# bpo-25095: Tell the client we're not sending any content along
298+
# with the response code.
297299
self.send_response(HTTPStatus.OK)
300+
self.send_header('Content-Length', 0)
298301
self.end_headers()
299302

300303
def do_ERROR(self):
@@ -311,8 +314,9 @@ def test_get(self):
311314
# To combat this, we send the test server the "Connection" header
312315
# with "close" for the value forcing the server and client to
313316
# terminate the socket allowing the test to resume.
314-
self.con.request('GET', '/', headers={'Content-Length': '0', 'Connection': 'close'})
317+
self.con.request('GET', '/', headers={'Connection': 'close'})
315318
self.con.getresponse()
319+
self.con.close()
316320

317321
self.assertTrue(
318322
err.getvalue().endswith('"GET / HTTP/1.1" 200 -\n'))

0 commit comments

Comments
 (0)
0