Browse Source

fixed extracting status code from NPH scripts (fixes #1125)

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@1948 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.17
Jan Kneschke 14 years ago
parent
commit
41e836b410
  1. 1
      NEWS
  2. 4
      src/mod_cgi.c
  3. 8
      tests/docroot/www/nph-status.pl
  4. 20
      tests/mod-cgi.t

1
NEWS

@ -20,6 +20,7 @@ NEWS
* fixed possible overflow in unix-socket path checks on BSD (#713)
* fixed extra Content-Length header on 1xx, 204 and 304 (#1002)
* fixed handling of duplicate If-Modified-Since to return 304
* fixed extracting status code from NPH scripts (#1125)
* removed config-check if passwd files exist (#1188)

4
src/mod_cgi.c

@ -255,8 +255,8 @@ static int cgi_response_parse(server *srv, connection *con, plugin_data *p, buff
status = strtol(s+9, NULL, 10);
if (con->http_status >= 100 &&
con->http_status < 1000) {
if (status >= 100 &&
status < 1000) {
/* we expected 3 digits and didn't got them */
con->parsed_response |= HTTP_STATUS;
con->http_status = status;

8
tests/docroot/www/nph-status.pl

@ -1,4 +1,10 @@
#!/usr/bin/perl
print "HTTP/1.0 30 FooBar\r\n";
my $status = 200;
if (defined $ENV{"QUERY_STRING"}) {
$status = $ENV{"QUERY_STRING"};
}
print "HTTP/1.0 ".$status." FooBar\r\n";
print "\r\n";

20
tests/mod-cgi.t

@ -8,7 +8,7 @@ BEGIN {
use strict;
use IO::Socket;
use Test::More tests => 16;
use Test::More tests => 18;
use LightyTest;
my $tf = LightyTest->new();
@ -40,11 +40,25 @@ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-
ok($tf->handle_http($t) == 0, 'perl via cgi + pathinfo');
$t->{REQUEST} = ( <<EOF
GET /nph-status.pl HTTP/1.0
GET /nph-status.pl?30 HTTP/1.0
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
ok($tf->handle_http($t) == 0, 'NPH + perl, Bug #14');
ok($tf->handle_http($t) == 0, 'NPH + perl, invalid status-code (#14)');
$t->{REQUEST} = ( <<EOF
GET /nph-status.pl?304 HTTP/1.0
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ];
ok($tf->handle_http($t) == 0, 'NPH + perl, setting status-code (#1125)');
$t->{REQUEST} = ( <<EOF
GET /nph-status.pl?200 HTTP/1.0
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
ok($tf->handle_http($t) == 0, 'NPH + perl, setting status-code');
$t->{REQUEST} = ( <<EOF
GET /get-header.pl?GATEWAY_INTERFACE HTTP/1.0

Loading…
Cancel
Save