3 # add current source dir to the include-path
4 # we need this for make distcheck
5 (my $srcdir = $0) =~ s
,/[^/]+$,/,;
11 use Test
::More tests
=> 9;
14 my $tf_real = LightyTest
->new();
15 my $tf_proxy = LightyTest
->new();
21 skip
"PHP already running on port 1026", 1 if $tf_real->listening_on(1026);
22 skip
"no php binary found", 1 unless $LightyTest::HAVE_PHP
;
23 ok
(-1 != ($php_child = $tf_real->spawnfcgi($ENV{'PHP'}, 1026)), "Spawning php");
27 ## 1. the real webserver
28 ## 2. the proxy server
30 $tf_real->{PORT
} = 2048;
31 $tf_real->{CONFIGFILE
} = 'lighttpd.conf';
33 $tf_proxy->{PORT
} = 2050;
34 $tf_proxy->{CONFIGFILE
} = 'proxy.conf';
36 ok
($tf_real->start_proc == 0, "Starting lighttpd") or goto cleanup
;
38 ok
($tf_proxy->start_proc == 0, "Starting lighttpd as proxy") or goto cleanup
;
40 $t->{REQUEST
} = ( <<EOF
41 GET /index.html HTTP/1.0
45 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
46 ok
($tf_proxy->handle_http($t) == 0, 'valid request');
48 $t->{REQUEST
} = ( <<EOF
49 GET /index.html HTTP/1.0
53 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Server' => 'Apache 1.3.29' } ];
54 ok
($tf_proxy->handle_http($t) == 0, 'drop Server from real server');
57 skip
"no PHP running on port 1026", 1 unless $tf_real->listening_on(1026);
58 $t->{REQUEST
} = ( <<EOF
59 GET /rewrite/all/some+test%3axxx%20with%20space HTTP/1.0
63 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/some+test%3axxx%20with%20space' } ];
64 ok
($tf_proxy->handle_http($t) == 0, 'rewrited urls work with encoded path');
67 ok
($tf_proxy->stop_proc == 0, "Stopping lighttpd proxy");
69 ok
($tf_real->stop_proc == 0, "Stopping lighttpd");
72 skip
"PHP not started, cannot stop it", 1 unless $php_child != -1;
73 ok
(0 == $tf_real->endspawnfcgi($php_child), "Stopping php");
81 $tf_real->endspawnfcgi($php_child) if $php_child != -1;