Changeset 1914

Show
Ignore:
Timestamp:
08/15/2007 11:38:49 AM (13 months ago)
Author:
jan
Message:

added protection that CONTENT_LENGTH is only added to the env
if it is > 0

- added the CGI test cases to the test-suite again
- added testcase to verify the patch works

Location:
trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/NEWS

    r1913 r1914  
    1616  * fixed different ETag length on 32/64 platforms (#1279) 
    1717  * fixed conditional dir-listing.exclude (#930) 
     18  * fixed CONTENT_LENGTH = -1 in mod_cgi (#1276) 
    1819 
    1920- 1.4.14 - ??? 
  • trunk/src/mod_cgi.c

    r1851 r1914  
    739739 
    740740#ifdef USE_OPENSSL 
    741        if (srv_sock->is_ssl) { 
    742                cgi_env_add(&env, CONST_STR_LEN("HTTPS"), CONST_STR_LEN("on")); 
    743        } 
     741                if (srv_sock->is_ssl) { 
     742                        cgi_env_add(&env, CONST_STR_LEN("HTTPS"), CONST_STR_LEN("on")); 
     743                } 
    744744#endif 
    745745 
    746746                /* request.content_length < SSIZE_MAX, see request.c */ 
    747                 ltostr(buf, con->request.content_length); 
    748                 cgi_env_add(&env, CONST_STR_LEN("CONTENT_LENGTH"), buf, strlen(buf)); 
     747                if (con->request.content_length > 0) { 
     748                        ltostr(buf, con->request.content_length); 
     749                        cgi_env_add(&env, CONST_STR_LEN("CONTENT_LENGTH"), buf, strlen(buf)); 
     750                } 
    749751                cgi_env_add(&env, CONST_STR_LEN("SCRIPT_FILENAME"), CONST_BUF_LEN(con->physical.path)); 
    750752                cgi_env_add(&env, CONST_STR_LEN("SCRIPT_NAME"), CONST_BUF_LEN(con->uri.path)); 
  • trunk/tests/default.conf

    r1432 r1914  
    2323#                               "mod_fastcgi", 
    2424#                               "mod_proxy", 
    25 #                               "mod_cgi", 
     25                                "mod_cgi", 
    2626                                "mod_compress", 
    2727                                "mod_userdir", 
     
    6060setenv.add-environment      = ( "TRAC_ENV" => "tracenv", "SETENV" => "setenv") 
    6161 
    62 # cgi.assign                  = ( ".pl"  => "/usr/bin/perl", 
    63 #                                ".cgi" => "/usr/bin/perl", 
    64 #                               ".py"  => "/usr/bin/python" ) 
     62cgi.assign                  = ( ".pl"  => "/usr/bin/perl", 
     63                                ".cgi" => "/usr/bin/perl", 
     64                                ".py"  => "/usr/bin/python" ) 
    6565                         
    6666userdir.include-user = ( "jan" ) 
  • trunk/tests/mod-cgi.t

    r1432 r1914  
    99use strict; 
    1010use IO::Socket; 
    11 use Test::More tests => 15; 
     11use Test::More tests => 16; 
    1212use LightyTest; 
    1313 
     
    1515my $t; 
    1616     
    17 SKIP: { 
    18   skip "disabled for now", 15; 
    1917ok($tf->start_proc == 0, "Starting lighttpd") or die(); 
    2018 
     
    119117ok($tf->handle_http($t) == 0, 'cgi-env: HTTP_HOST'); 
    120118 
     119$t->{REQUEST}  = ( <<EOF 
     120GET /get-header.pl?CONTENT_LENGTH HTTP/1.0 
     121Host: www.example.org 
     122Connection: close 
     123EOF 
     124 ); 
     125$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '+Content-Length' => '' } ]; 
     126ok($tf->handle_http($t) == 0, 'cgi-env: CONTENT_LENGTH'); 
     127 
    121128ok($tf->stop_proc == 0, "Stopping lighttpd"); 
    122 } 
     129