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 orsenthil, sirosen
Date 2021-05-02.01:13:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Ach! Sorry! I didn't even realize this but the issue only arises when you are modifying the handler to set the protocol to HTTP/1.1 .

In HTTP/1.0 , there's no notion of persistent connections, so the issue does not arise.

But when the protocol version changes to 1.1 , persistent connections are the norm, and curl will wait indefinitely.

The following short script is sufficient to reproduce:
import http.server

class CustomRequestHandler(http.server.SimpleHTTPRequestHandler):
    protocol_version = "HTTP/1.1"

with http.server.HTTPServer(("", 8000), CustomRequestHandler) as httpd:
    except KeyboardInterrupt:
        print("\nKeyboard interrupt received, exiting.")

After double-checking the docs, the current doc for `protocol_version` [1] is quite clear about this:
"your server must then include an accurate Content-Length header (using send_header()) in all of its responses to clients"

I still think the fix I proposed is an improvement. Setting a Content-Length isn't forbidden in HTTP/1.0 , and it guarantees good behavior when HTTP/1.1 is used.

Date User Action Args
2021-05-02 01:13:21sirosensetrecipients: + sirosen, orsenthil
2021-05-02 01:13:20sirosensetmessageid: <>
2021-05-02 01:13:20sirosenlinkissue43972 messages
2021-05-02 01:13:20sirosencreate