The simplest web server in python
(python2.7, windows10):
python -mSimpleHTTPServer
Gives static files. curl
shows that the HTTP/1.0
protocol is being used (which corresponds to the HTTPServer documentation):
curl -s -D - http://localhost:8000/foo.jpg -o nul HTTP/1.0 200 OK Server: SimpleHTTP/0.6 Python/2.7.11 Date: Sun, 07 Aug 2016 07:21:20 GMT Content-type: image/jpeg Content-Length: 25803 Last-Modified: Thu, 30 Jun 2016 06:13:58 GMT
At the same time, when requested through a browser (Crome, Firefox), HTTP/1.1
obtained (visible through the developer console, on the network
tab):
HTTP/1.1 200 OK Server: SimpleHTTP/0.6 Python/2.7.11 Date: Sun, 07 Aug 2016 07:21:42 GMT Content-type: image/jpeg Content-Length: 25803 Last-Modified: Thu, 30 Jun 2016 06:13:58 GMT
Accordingly, the browser does not close the connection after the request.
In both cases, the output using print
in the BaseHTTPServer.py
source shows the first line of the client request as GET /foo.jpg HTTP/1.1
. In the answer in both cases (also in print
in the server code) the first line: HTTP/1.0 200 OK
.
Proxy server is not used.
If you request from a browser from a virtual machine, the http version does not change ( HTTP/1.0
remains).
What could be the reason for this difference?
C:\Python27\Lib\site-packages\http\client.py
- Vladimir Gamalyan