This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author sirosen
Recipients sirosen
Date 2021-04-29.01:06:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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):
        if code == HTTPStatus.MOVED_PERMANENTLY:
            self.send_header("Content-Length", "0")
Date User Action Args
2021-04-29 01:06:37sirosensetrecipients: + sirosen
2021-04-29 01:06:37sirosensetmessageid: <>
2021-04-29 01:06:37sirosenlinkissue43972 messages
2021-04-29 01:06:36sirosencreate