Message392272
If you use the `http.server` simple server and handler to serve a directory, navigating to a directory name without a trailing slash will trigger a 301 to add the trailing slash.
For example, if "foo/" is a directory under the file server, a GET for "/foo" will receive a 301 Moved Permanently response with a Location header pointing at "/foo/".
However, the response is sent without a "Content-Length: 0" and the connection is not closed. Unfortunately, certain clients will hang indefinitely and wait under these conditions, without processing the redirect. In my testing, curl 7.68 and Firefox 87 both exhibted this behavior.
If a Content-Length header is set, these clients behave correctly.
For example, subclass the handler and add
def send_response(self, code):
super().send_response(code)
if code == HTTPStatus.MOVED_PERMANENTLY:
self.send_header("Content-Length", "0") |
|
Date |
User |
Action |
Args |
2021-04-29 01:06:37 | sirosen | set | recipients:
+ sirosen |
2021-04-29 01:06:37 | sirosen | set | messageid: <1619658397.03.0.0874955697236.issue43972@roundup.psfhosted.org> |
2021-04-29 01:06:37 | sirosen | link | issue43972 messages |
2021-04-29 01:06:36 | sirosen | create | |
|