-
Notifications
You must be signed in to change notification settings - Fork 10
Description
Description
In the case of a general 404 trying to access a file that doesn't exist, Cling incorrectly adds an additional Content-type: text/plain after every 404 received. This means that if the server sends 3 404 responses, the header will provide 3 Content-type: text/plain headers. For 10,000 responses, 10,000 duplicate headers.
This is persistent until the Headers variable is cleared or the service is restarted.
Fix
I believe that in the LOC below, self.message is never False so in every case, it will append another value.
Line 109 in 309ddc3
| if self.message: |
POC
Run a server
from static import Cling
from wsgiref.simple_server import make_server
my_app = Cling("/home/antitree/")
make_server("localhost", 9999, my_app).serve_forever()
Connect to a file that doesn't exist
wget --server-response http://localhost:9999/TEST
Response
Connecting to 127.0.0.1:9999... connected.
HTTP request sent, awaiting response...
HTTP/1.0 404 Not Found
Date: Sun, 07 Aug 2016 18:04:28 GMT
Server: WSGIServer/0.2 CPython/3.5.2
Content-type: text/plain
Content-Length: 13
Content-type: text/plain
Repeat, and second response
Connecting to 127.0.0.1:9999... connected.
HTTP request sent, awaiting response...
HTTP/1.0 404 Not Found
Date: Sun, 07 Aug 2016 18:04:28 GMT
Server: WSGIServer/0.2 CPython/3.5.2
Content-type: text/plain
Content-Length: 13
Content-type: text/plain
Content-type: text/plain
Repeat 10,000 times to see that the headers are repeatedly added to.