Changeset 2099

Show
Ignore:
Timestamp:
02/27/2008 06:35:42 PM (5 months ago)
Author:
stbuehler
Message:

r2123@chromobil: stefan | 2008-02-27 19:30:54 +0100
do not generate a "Content-Length: 0" header for HEAD requests, added test too

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/lighttpd-1.4.x/NEWS

    r2098 r2099  
    4242  * do not suppress content on "307 Temporary Redirect" (#1412) 
    4343  * fixed Content-Length header if response body gets removed in connections.c (#1412, part 2) 
     44  * do not generate a "Content-Length: 0" header for HEAD requests, added test too 
    4445 
    4546- 1.4.18 - 2007-09-09 
  • branches/lighttpd-1.4.x/src/connections.c

    r2098 r2099  
    546546                                        buffer_reset(ds->value); // Headers with empty values are ignored for output 
    547547                                } 
    548                         } else if (qlen >= 0) { 
     548                        } else if (qlen > 0 || con->request.http_method != HTTP_METHOD_HEAD) { 
    549549                                /* qlen = 0 is important for Redirects (301, ...) as they MAY have 
    550550                                 * a content. Browsers are waiting for a Content otherwise 
    551551                                 */ 
    552                                 buffer_copy_off_t(srv->tmp_buf, chunkqueue_length(con->write_queue)); 
     552                                buffer_copy_off_t(srv->tmp_buf, qlen); 
    553553 
    554554                                response_header_overwrite(srv, con, CONST_STR_LEN("Content-Length"), CONST_BUF_LEN(srv->tmp_buf)); 
  • branches/lighttpd-1.4.x/tests/mod-fastcgi.t

    r2027 r2099  
    88 
    99use strict; 
    10 use Test::More tests => 46
     10use Test::More tests => 47
    1111use LightyTest; 
    1212 
     
    224224 
    225225SKIP: { 
    226         skip "no php found", 4 unless -x "/usr/bin/php-cgi";  
     226        skip "no php found", 5 unless -x "/usr/bin/php-cgi";  
    227227        $tf->{CONFIGFILE} = 'fastcgi-13.conf'; 
    228228        ok($tf->start_proc == 0, "Starting lighttpd with $tf->{CONFIGFILE}") or die(); 
     
    234234        $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; 
    235235        ok($tf->handle_http($t) == 0, 'FastCGI + local spawning'); 
     236 
     237        $t->{REQUEST} = ( <<EOF 
     238HEAD /indexfile/index.php HTTP/1.0 
     239Host: www.example.org 
     240EOF 
     241 ); 
     242        $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '-Content-Length' => '0' } ]; 
     243        # Of course a valid content-length != 0 would be ok, but we assume for now that such one is not generated. 
     244        ok($tf->handle_http($t) == 0, 'Check for buggy content length with HEAD'); 
    236245 
    237246        $t->{REQUEST}  = ( <<EOF