Project

General

Profile

Bug #1925

lighttpd returns invalid chunked encoding for 204 responses

Added by james82@gmail.com over 10 years ago. Updated about 3 years ago.

Status:
Obsolete
Priority:
Normal
Assignee:
-
Category:
-
Target version:
Start date:
2009-03-03
Due date:
% Done:

0%

Estimated time:
Missing in 1.5.x:
Yes

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)

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 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');
?>

chunked-encoding-patch.txt (1018 Bytes) chunked-encoding-patch.txt james82@gmail.com, 2009-03-03 20:31

History

#1

Updated by james82@gmail.com over 10 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.

#2

Updated by james82@gmail.com over 10 years ago

  • Status changed from New to Patch Pending
  • Target version set to 6
#3

Updated by james82@gmail.com over 10 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

#4

Updated by stbuehler over 10 years ago

  • Target version changed from 6 to 1.5.0
#5

Updated by gstrauss over 3 years ago

1.5.x branch has been abandoned. Please mark ticket fixed.

#6

Updated by gstrauss about 3 years ago

  • Missing in 1.5.x set to Yes
#7

Updated by gstrauss about 3 years ago

  • Status changed from Patch Pending to Obsolete

Also available in: Atom