Browse Source

r2123@chromobil: stefan | 2008-02-27 19:30:54 +0100

do not generate a "Content-Length: 0" header for HEAD requests, added test too


git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2099 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.19
Stefan Bühler 14 years ago
parent
commit
debd30876a
  1. 1
      NEWS
  2. 4
      src/connections.c
  3. 13
      tests/mod-fastcgi.t

1
NEWS

@ -41,6 +41,7 @@ NEWS
* fixed mod-proxy.t to run with a builddir outside of the src dir
* do not suppress content on "307 Temporary Redirect" (#1412)
* fixed Content-Length header if response body gets removed in connections.c (#1412, part 2)
* do not generate a "Content-Length: 0" header for HEAD requests, added test too
- 1.4.18 - 2007-09-09

4
src/connections.c

@ -545,11 +545,11 @@ static int connection_handle_write_prepare(server *srv, connection *con) {
if (NULL != (ds = (data_string*) array_get_element(con->response.headers, "Content-Length"))) {
buffer_reset(ds->value); // Headers with empty values are ignored for output
}
} else if (qlen >= 0) {
} else if (qlen > 0 || con->request.http_method != HTTP_METHOD_HEAD) {
/* qlen = 0 is important for Redirects (301, ...) as they MAY have
* a content. Browsers are waiting for a Content otherwise
*/
buffer_copy_off_t(srv->tmp_buf, chunkqueue_length(con->write_queue));
buffer_copy_off_t(srv->tmp_buf, qlen);
response_header_overwrite(srv, con, CONST_STR_LEN("Content-Length"), CONST_BUF_LEN(srv->tmp_buf));
}

13
tests/mod-fastcgi.t

@ -7,7 +7,7 @@ BEGIN {
}
use strict;
use Test::More tests => 46;
use Test::More tests => 47;
use LightyTest;
my $tf = LightyTest->new();
@ -223,7 +223,7 @@ EOF
}
SKIP: {
skip "no php found", 4 unless -x "/usr/bin/php-cgi";
skip "no php found", 5 unless -x "/usr/bin/php-cgi";
$tf->{CONFIGFILE} = 'fastcgi-13.conf';
ok($tf->start_proc == 0, "Starting lighttpd with $tf->{CONFIGFILE}") or die();
$t->{REQUEST} = ( <<EOF
@ -234,6 +234,15 @@ EOF
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
ok($tf->handle_http($t) == 0, 'FastCGI + local spawning');
$t->{REQUEST} = ( <<EOF
HEAD /indexfile/index.php HTTP/1.0
Host: www.example.org
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '-Content-Length' => '0' } ];
# Of course a valid content-length != 0 would be ok, but we assume for now that such one is not generated.
ok($tf->handle_http($t) == 0, 'Check for buggy content length with HEAD');
$t->{REQUEST} = ( <<EOF
GET /get-env.php?env=MAIL HTTP/1.0
Host: www.example.org

Loading…
Cancel
Save