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
=> 7;
14 my $tf_real = LightyTest
->new();
15 my $tf_proxy = LightyTest
->new();
20 ## 1. the real webserver
21 ## 2. the proxy server
23 $tf_real->{PORT
} = 2048;
24 $tf_real->{CONFIGFILE
} = 'lighttpd.conf';
26 $tf_proxy->{PORT
} = 2050;
27 $tf_proxy->{CONFIGFILE
} = 'proxy.conf';
29 ok
($tf_real->start_proc == 0, "Starting lighttpd") or goto cleanup
;
31 ok
($tf_proxy->start_proc == 0, "Starting lighttpd as proxy") or goto cleanup
;
33 $t->{REQUEST
} = ( <<EOF
34 GET /index.html HTTP/1.0
38 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
39 ok
($tf_proxy->handle_http($t) == 0, 'valid request');
41 $t->{REQUEST
} = ( <<EOF
42 GET /index.html HTTP/1.0
46 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Server' => 'Apache 1.3.29' } ];
47 ok
($tf_proxy->handle_http($t) == 0, 'drop Server from real server');
49 $t->{REQUEST
} = ( <<EOF
50 GET /rewrite/all/some+test%3axxx%20with%20space HTTP/1.0
54 $t->{RESPONSE
} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '/some+test%3Axxx%20with%20space' } ];
55 ok
($tf_proxy->handle_http($t) == 0, 'rewrited urls work with encoded path');
57 ok
($tf_proxy->stop_proc == 0, "Stopping lighttpd proxy");
59 ok
($tf_real->stop_proc == 0, "Stopping lighttpd");