Message392650
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:
try:
httpd.serve_forever()
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.
[1] https://docs.python.org/3/library/http.server.html#http.server.BaseHTTPRequestHandler.protocol_version |
|
Date |
User |
Action |
Args |
2021-05-02 01:13:21 | sirosen | set | recipients:
+ sirosen, orsenthil |
2021-05-02 01:13:20 | sirosen | set | messageid: <1619918000.95.0.845338400556.issue43972@roundup.psfhosted.org> |
2021-05-02 01:13:20 | sirosen | link | issue43972 messages |
2021-05-02 01:13:20 | sirosen | create | |
|