waxmiguelito / mongoose

Automatically exported from code.google.com/p/mongoose
MIT License
0 stars 0 forks source link

wrong Contnet-Type when a static file is not modified #229

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
If a static file has not been modified mongoose returns a 304 Not Modified 
error response.  This is fine, but Chrome on Windows reports a warning in the 
javascript debbugger that the static files which have not changed have an 
incorrect MIME type.  The Content-Type in the send_http_error is always 
"text/plain".  I made a patch so that the Content-type: text/plain header in 
only included in the response if the Content-Length is greater than zero.  I am 
not sure if mongoose is correct or if Chrome is correct, but after this patch 
there are no more Chrome warnings.

Original issue reported on code.google.com by dcraw...@gmail.com on 12 Feb 2011 at 4:41

Attachments:

GoogleCodeExporter commented 9 years ago
RFC 2616 says about 304 responses:
(http://tools.ietf.org/html/rfc2616#section-10.3.5)

If the conditional GET used a strong cache validator (see section
13.3.3), the response SHOULD NOT include other entity-headers.
Otherwise (i.e., the conditional GET used a weak validator), the
response MUST NOT include other entity-headers; this prevents
inconsistencies between cached entity-bodies and updated headers.

Content-Type is entity header and not listed above this paragraph,
so clearly qualifies as "other entity-headers".

I agree with you and Maxim Dounin and I also think there should not be a 
Content-Type in a 304 response.

source/see also: http://forum.nginx.org/read.php?2,126124

Original comment by mevdsc...@gmail.com on 19 Jul 2011 at 6:57

GoogleCodeExporter commented 9 years ago
I tested with Apache2 and mongoose and it's output differs on 304 requests (see 
attached file) Apache2 is (correctly) not setting a Content-Type header while 
mongoose is doing this. Note that Firefox5 ignores the erroneous header on my 
machine.

Original comment by mevdsc...@gmail.com on 19 Jul 2011 at 7:24

Attachments:

GoogleCodeExporter commented 9 years ago
After I manually applied the patch by dcraw I saw that it does as it says on 
the tin: remove the Content-Type header on errors with an empty body.

Original comment by mevdsc...@gmail.com on 19 Jul 2011 at 7:34

GoogleCodeExporter commented 9 years ago
Removed content-type header, 
https://github.com/valenok/mongoose/commit/1e632d32154800e02a4aad5677c432fa66ffa
002
Thanks!

Original comment by valenok on 22 Sep 2012 at 2:21