- fixed 404 testsuite

- added optional fastcgi handler

git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@1898 152afb58-edef-0310-8abb-c4023f1b3aa9
svn/tags/lighttpd-1.4.17
Marcus Rückert 16 years ago
parent 984f5caf57
commit 029d32039c

@ -1,4 +1,6 @@
debug.log-request-handling = "enable"
debug.log-response-header = "enable"
debug.log-request-header = "enable"
server.document-root = env.SRCDIR + "/tmp/lighttpd/servers/www.example.org/pages/"
server.pid-file = env.SRCDIR + "/tmp/lighttpd/lighttpd.pid"
@ -14,6 +16,7 @@ server.tag = "Apache 1.3.29"
server.modules = (
"mod_fastcgi",
"mod_cgi",
"mod_accesslog" )
@ -26,15 +29,21 @@ mimetype.assign = ( ".html" => "text/html" )
cgi.assign = (".pl" => "/usr/bin/perl" )
# fastcgi.server += ( "/404.pl" =>
# ( "404-handler" =>
# (
# "socket" => env.SRCDIR + "/tmp/pl-404-fastcgi-1.socket",
# "bin-path" => server.document-root + "/404.pl",
# "max-procs" => 1,
# "check-local" => "disable",
# "broken-scriptfilename" => "enable",
# )
# ),
# )
$HTTP["url"] =~ "^/static/" {
server.error-handler-404 = "/404.html"
}
else $HTTP["url"] =~ "^/dynamic/200/" {
server.error-handler-404 = "/404.pl"
}
else $HTTP["url"] =~ "^/dynamic/302/" {
server.error-handler-404 = "/404.pl"
}
else $HTTP["url"] =~ "^/dynamic/404/" {
else $HTTP["url"] =~ "^/dynamic/" {
server.error-handler-404 = "/404.pl"
}

@ -23,15 +23,19 @@ use LightyTest;
my $tf = LightyTest->new();
my $t;
$tf->{CONFIGFILE} = '404-handler.conf';
ok($tf->start_proc == 0, "Starting lighttpd") or die();
$t->{REQUEST} = ( <<EOF
GET /static/notfound HTTP/1.0
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404, 'HTTP-Content' => "static not found\n" } ];
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => "static not found\n" } ];
ok($tf->handle_http($t) == 0, '404 handler => static');
#
#
#
$t->{REQUEST} = ( <<EOF
GET /dynamic/200/notfound HTTP/1.0
EOF
@ -47,11 +51,11 @@ $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 302, 'Locat
ok($tf->handle_http($t) == 0, '404 handler => dynamic(302)');
$t->{REQUEST} = ( <<EOF
GET /dynamic/200/notfound HTTP/1.0
GET /dynamic/404/notfound HTTP/1.0
EOF
);
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404, 'HTTP-Content' => "Not found here\n" } ];
ok($tf->handle_http($t) == 0, '404 handler => dynamic(200)');
ok($tf->handle_http($t) == 0, '404 handler => dynamic(404)');
ok($tf->stop_proc == 0, "Stopping lighttpd");

@ -0,0 +1,27 @@
#!/usr/bin/perl
#use CGI qw/:standard/;
use CGI::Fast qw(:standard);
my $cgi = new CGI;
while (new CGI::Fast) {
my $request_uri = $ENV{'REQUEST_URI'};
print (STDERR "REQUEST_URI: $request_uri\n");
if ($request_uri =~ m/^\/dynamic\/200\// ) {
print header ( -status => 200,
-type => 'text/plain' );
print ("found here\n");
}
elsif ($request_uri =~ m|^/dynamic/302/| ) {
print header( -status=>302,
-location => 'http://www.example.org/');
}
elsif ($request_uri =~ m/^\/dynamic\/404\// ) {
print header ( -status => 404
-type => 'text/plain' );
print ("Not found here\n");
}
else {
print header ( -status => 500,
-type => 'text/plain');
print ("huh\n");
};
};

@ -8,7 +8,7 @@ if ($request_uri =~ m/^\/dynamic\/200\// ) {
-type => 'text/plain' );
print ("found here\n");
}
elsif ($request_uri =~ m|^/dynamic/301/| ) {
elsif ($request_uri =~ m|^/dynamic/302/| ) {
print header( -status=>302,
-location => 'http://www.example.org/');
}

Loading…
Cancel
Save