Bug #1925
closedlighttpd returns invalid chunked encoding for 204 responses
Description
Currently, if a CGI script returns "Status: 204 No Content", lighttpd returns a malformed response that confuses certain clients, including curl. Curl complains about this problem by printing the following error message: "transfer closed with outstanding read data remaining".
The following recipe duplicates the problem:
1) Create a test CGI script called "test.cgi" that returns 204 No Content.
2) Use curl -sv to access test.cgi
The attached patch (chunked-encoding-patch.txt) should fix the problem.
Cheers,
David James
Transcript of problem:$ curl -v 'http://localhost/test.cgi' /alexa/lighttpd/vhosts/default
- About to connect() to localhost port 80 (#0)
- Trying 127.0.0.1... connected
- Connected to localhost (127.0.0.1) port 80 (#0)
< HTTP/1.1 204 No ContentGET /test.cgi HTTP/1.1
User-Agent: curl/7.18.2 (x86_64-unknown-linux-gnu) libcurl/7.19.3 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
Host: localhost
Accept: */*
< X-Powered-By: PHP/5.1.6
< Content-type: text/html
< Transfer-Encoding: chunked
< Date: Tue, 03 Mar 2009 20:19:24 GMT
< Server: lighttpd
<
- transfer closed with outstanding read data remaining
- Closing connection #0
curl: (18) transfer closed with outstanding read data remaining
Example test.cgi:
#!/usr/bin/php-cgi
header('Status: 204 No Content');
?>
Files
Updated by james82@gmail.com over 15 years ago
My transcript got a bit mangled above by redmine. Here's a cleaner version of the curl transcript.
$ curl -v http://localhost/test.cgi * About to connect() to localhost port 80 (#0) * Trying 127.0.0.1... connected * Connected to localhost (127.0.0.1) port 80 (#0) > GET /test.cgi HTTP/1.1 > User-Agent: curl/7.18.2 (x86_64-unknown-linux-gnu) libcurl/7.19.3 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 > Host: localhost > Accept: */* > < HTTP/1.1 204 No Content < X-Powered-By: PHP/5.1.6 < Content-type: text/html < Transfer-Encoding: chunked < Date: Tue, 03 Mar 2009 22:41:38 GMT < Server: lighttpd < * transfer closed with outstanding read data remaining * Closing connection #0 curl: (18) transfer closed with outstanding read data remaining
After the patch, the curl transcript looks like this:
* About to connect() to localhost port 80 (#0) * Trying 127.0.0.1... connected * Connected to localhost (127.0.0.1) port 80 (#0) > GET /test.cgi HTTP/1.1 > User-Agent: curl/7.18.2 (x86_64-unknown-linux-gnu) libcurl/7.19.3 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 > Host: localhost > Accept: */* > < HTTP/1.1 204 No Content < X-Powered-By: PHP/5.1.6 < Content-type: text/html < Date: Tue, 03 Mar 2009 22:43:10 GMT < Server: lighttpd < * Connection #0 to host localhost left intact * Closing connection #0
My patch disables sending chunked encoding for 1xx, 204, and 304 responses, fixing a regression introduced by r1946. I got the list of HTTP codes that this should apply to from r1946.
Updated by james82@gmail.com over 15 years ago
- Status changed from New to Patch Pending
- Target version set to 6
Updated by james82@gmail.com over 15 years ago
Update: This bug was actually introduced in r1850. Reverting r1850 fixes the problem. stbuehler fixed this issue in r2154, but this fix needs to be merged to the 1.5.x branch
Updated by gstrauss almost 9 years ago
1.5.x branch has been abandoned. Please mark ticket fixed.
Updated by gstrauss over 8 years ago
- Status changed from Patch Pending to Obsolete
Also available in: Atom