3
# combinations we have to test:
5
# 404-handler -> static file (verify content)
6
# 404-handler -> fastcgi
8
# returning 302 + Location
10
# returning no status -> 200
13
# add current source dir to the include-path
14
# we need this for make distcheck
15
(my $srcdir = $0) =~ s#/[^/]+$#/#;
16
unshift @INC, $srcdir;
21
use Test::More tests => 8;
24
my $tf = LightyTest->new();
26
$tf->{CONFIGFILE} = '404-handler.conf';
28
ok($tf->start_proc == 0, "Starting lighttpd") or die();
30
$t->{REQUEST} = ( <<EOF
31
GET /static/notfound HTTP/1.0
34
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => "static not found\n" } ];
35
ok($tf->handle_http($t) == 0, '404 handler => static');
40
$t->{REQUEST} = ( <<EOF
41
GET /dynamic/200/notfound HTTP/1.0
44
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => "found here\n" } ];
45
ok($tf->handle_http($t) == 0, '404 handler => dynamic(200)');
47
$t->{REQUEST} = ( <<EOF
48
GET /dynamic/302/notfound HTTP/1.0
51
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 302, 'Location' => "http://www.example.org/" } ];
52
ok($tf->handle_http($t) == 0, '404 handler => dynamic(302)');
54
$t->{REQUEST} = ( <<EOF
55
GET /dynamic/404/notfound HTTP/1.0
58
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404, 'HTTP-Content' => "Not found here\n" } ];
59
ok($tf->handle_http($t) == 0, '404 handler => dynamic(404)');
61
$t->{REQUEST} = ( <<EOF
62
GET /dynamic/nostatus/notfound HTTP/1.0
65
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => "found here\n" } ];
66
ok($tf->handle_http($t) == 0, '404 handler => dynamic(nostatus)');
68
$t->{REQUEST} = ( <<EOF
69
GET /send404.pl HTTP/1.0
72
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404, 'HTTP-Content' => "send404\n" } ];
73
ok($tf->handle_http($t) == 0, '404 generated by CGI should stay 404');
75
ok($tf->stop_proc == 0, "Stopping lighttpd");