jetti777Ltd / mochiweb

Automatically exported from code.google.com/p/mochiweb
Other
0 stars 0 forks source link

Content-Length should not be produced in some responses #27

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
mochiweb_request produces a Content-Length header of 0 in the case of all
GET/HEAD responses with an empty body.

However, there are some cases where this is explicitly forbidden.  For
example, when returning a 304 (section 10.3.5 of rfc 2616) it is explicitly
forbidden to return entity headers other than those named as this can cause
cache corruption.

Original issue reported on code.google.com by justin.s...@gmail.com on 2 Feb 2009 at 3:00

GoogleCodeExporter commented 8 years ago
r94

Original comment by bob.ippo...@gmail.com on 16 Feb 2009 at 7:31

GoogleCodeExporter commented 8 years ago
r94 changes the logic to only include a "Content-Length: 0" for status codes 
200-299.

I think this doesn't work, as it (for example) causes empty 301 redirects to 
stall while the client waits for chunks or 
the connection to close. Here's an example with curl and CouchDB:

-------------------------------------------------------------------------------
curl -vi http://localhost:5984/testing/_design%2Fpython
* About to connect() to localhost port 5984 (#0)
*   Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 5984 (#0)
> GET /testing/_design%2Fpython HTTP/1.1
> User-Agent: curl/7.19.2 (i386-apple-darwin9.6.0) libcurl/7.19.2 zlib/1.2.3
> Host: localhost:5984
> Accept: */*
> 
< HTTP/1.1 301 Moved Permanently
HTTP/1.1 301 Moved Permanently
< Server: CouchDB/0.9.0a747380 (Erlang OTP/R12B)
Server: CouchDB/0.9.0a747380 (Erlang OTP/R12B)
< Location: http://localhost:5984/testing/_design/python
Location: http://localhost:5984/testing/_design/python
< Date: Tue, 24 Feb 2009 21:04:50 GMT
Date: Tue, 24 Feb 2009 21:04:50 GMT
* no chunk, no close, no size. Assume close to signal end

[… time passes …]

< 
* Closing connection #0
-------------------------------------------------------------------------------

I think we should special-case only those status codes that specifically 
prohibit a content-length header. Otherwise, 
the old behavior had the advantage of not actually causing any problems in the 
real world AFAIK :P

Original comment by cmlenz on 24 Feb 2009 at 9:17

GoogleCodeExporter commented 8 years ago
I'd reopen this issue but lack permissions. Or should I file a new issue for 
this?

Original comment by cmlenz on 24 Feb 2009 at 9:18

GoogleCodeExporter commented 8 years ago
Reverted in r97, marking as invalid unless a patch is provided that doesn't 
break anything

Original comment by bob.ippo...@gmail.com on 24 Feb 2009 at 9:20