diff options
author | Jan Kneschke <jan@kneschke.de> | 2007-08-18 11:35:27 +0000 |
---|---|---|
committer | Jan Kneschke <jan@kneschke.de> | 2007-08-18 11:35:27 +0000 |
commit | 41e836b4105cee225f4759e63a8e037e964bc695 (patch) | |
tree | cf821ec80df752cbf640215a817fbaab55d9ebf6 | |
parent | f67cdb67df59e921c19493b8616b7d8e80807d47 (diff) | |
download | lighttpd-git-41e836b4105cee225f4759e63a8e037e964bc695.tar.gz |
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
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | src/mod_cgi.c | 4 | ||||
-rwxr-xr-x | tests/docroot/www/nph-status.pl | 8 | ||||
-rwxr-xr-x | tests/mod-cgi.t | 20 |
4 files changed, 27 insertions, 6 deletions
@@ -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) diff --git a/src/mod_cgi.c b/src/mod_cgi.c index 42c2208e..e87cb18d 100644 --- a/src/mod_cgi.c +++ b/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; diff --git a/tests/docroot/www/nph-status.pl b/tests/docroot/www/nph-status.pl index 528791be..d817c7fd 100755 --- a/tests/docroot/www/nph-status.pl +++ b/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"; diff --git a/tests/mod-cgi.t b/tests/mod-cgi.t index f3952879..b89a1af6 100755 --- a/tests/mod-cgi.t +++ b/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 |