Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permanent Content-type duplication in response after 404 #12

Open
antitree opened this issue Aug 7, 2016 · 0 comments
Open

Permanent Content-type duplication in response after 404 #12

antitree opened this issue Aug 7, 2016 · 0 comments

Comments

@antitree
Copy link

antitree commented Aug 7, 2016

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.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant