summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_httpservers.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-05-06 19:48:36 (GMT)
committerGitHub <noreply@github.com>2021-05-06 19:48:36 (GMT)
commit058f9b27d3838f04bbb313074941e9f9946a33bc (patch)
tree9987fe815ff0a1746afa31fb50dcc4b191c7e3d0 /Lib/test/test_httpservers.py
parent34fc6dd8fd2d9d6e60b0917f8a24cc5d63a03016 (diff)
downloadcpython-058f9b27d3838f04bbb313074941e9f9946a33bc.zip
cpython-058f9b27d3838f04bbb313074941e9f9946a33bc.tar.gz
cpython-058f9b27d3838f04bbb313074941e9f9946a33bc.tar.bz2
bpo-43972: Set content-length to 0 for http.server.SimpleHTTPRequestHandler 301s (GH-25705)
* Set content-length for simple http server 301s When http.server.SimpleHTTPRequestHandler sends a 301 (Moved Permanently) due to a missing file, it does not set a Content-Length of 0. Unfortunately, certain clients can be left waiting for the connection to be closed in this circumstance, even though no body will be sent. At time of writing, both curl and Firefox demonstrate this behavior. * Test Content-Length on simple http server redirect When serving a redirect, the SimpleHTTPRequestHandler will now send `Content-Length: 0`. Several tests for http.server already cover various behaviors and checks including redirection. This change only adds one check for the expected Content-Length on the simplest case for a redirect. * Add news entry for SimpleHTTPRequestHandler fix * Clarify the specific kind of 301 Co-authored-by: Senthil Kumaran <skumaran@gatech.edu> (cherry picked from commit fb427255614fc1f740e7785554c1da8ca39116c2) Co-authored-by: Stephen Rosen <sirosen@globus.org>
Diffstat (limited to 'Lib/test/test_httpservers.py')
-rw-r--r--Lib/test/test_httpservers.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
index 6b17817..cb0a3aa 100644
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -428,6 +428,7 @@ class SimpleHTTPServerTestCase(BaseTestCase):
self.check_status_and_reason(response, HTTPStatus.OK)
response = self.request(self.base_url)
self.check_status_and_reason(response, HTTPStatus.MOVED_PERMANENTLY)
+ self.assertEqual(response.getheader("Content-Length"), "0")
response = self.request(self.base_url + '/?hi=2')
self.check_status_and_reason(response, HTTPStatus.OK)
response = self.request(self.base_url + '?hi=1')