May I direct your attention to the second sentence of my post?
It fixes an issue in the Python built-in HTTP server that causes it to hang under concurrent connections.
First, run the built-in Python web server:
[term1]$ python -m SimpleHTTPServer 8080
Then connect to it with a client that doesn't immediately send a request, such as `netcat`. This simulates the behavior of modern browsers, which seem to set up a pool of pre-established connections.
[term2]$ nc localhost 8080
Now try to get a page from the server via Curl (or wget, etc). It will hang after sending the request, because the server's single thread is trying to serve the idle connection.
[term3]$ curl -v http://127.0.0.1:8080
* Trying 127.0.0.1:8080...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.68.0
> Accept: */*
>
In real life, the behavior I saw was that I'd try to connect to the server with Chrome and it would hang after the pages had partially loaded.
I think this is a problem that's long been fixed; I tested your command and it seems to work as expected for me in Python 3.10 anyway. And I've been using the "python -mhttp.server" frequently for years, and never experienced any of these problems.
It fixes an issue in the Python built-in HTTP server that causes it to hang under concurrent connections.
First, run the built-in Python web server:
Then connect to it with a client that doesn't immediately send a request, such as `netcat`. This simulates the behavior of modern browsers, which seem to set up a pool of pre-established connections. Now try to get a page from the server via Curl (or wget, etc). It will hang after sending the request, because the server's single thread is trying to serve the idle connection. In real life, the behavior I saw was that I'd try to connect to the server with Chrome and it would hang after the pages had partially loaded.