When the QHttpServer is done serving a file it leaves the socket open. This causes some clients to wait infinitely for the more data, and not realize that the entire file contents has been transfered.
Note, that in contrast, on error, the socket is closed as expected.
The following example shows the problem:
.1. Create a root directory, populate it, and start the http server:
.2. Connect to the server by telnet and first trigger an error. Note that the connection is closed at the end of the error message.
> telnet localhost 8899
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /foo.txt HTTP/1.1
HTTP/1.0 404 NOT FOUND
Content-Length: 366
Content-Type: text/html
<!DOCTYPE html><html><head><meta charset="utf-8"><meta name="viewport" \
content="width=device-width, initial-scale=1.0"><title>404 NOT FOUND</title></head><body>\
<h1>404 NOT FOUND</h1><p>An error has occurred while trying to display the requested \
resource. Please contact the website owner if this error persists.</p><hr><p><em>QHttpEngine \
0.1.0</em></p></body></html>\
Connection closed by foreign host.
.3. Request a file. The connection is never closed.
> telnet localhost 8899
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /a.txt HTTP/1.1
HTTP/1.0 200 OK
Content-Length: 5
Content-Type: text/plain
aaaa
^] ← Done manually!
telnet> quit
Connection closed.
When the QHttpServer is done serving a file it leaves the socket open. This causes some clients to wait infinitely for the more data, and not realize that the entire file contents has been transfered.
Note, that in contrast, on error, the socket is closed as expected.
The following example shows the problem:
.1. Create a root directory, populate it, and start the http server:
.2. Connect to the server by telnet and first trigger an error. Note that the connection is closed at the end of the error message.
.3. Request a file. The connection is never closed.