2005-09-01 11:44:57 +00:00
|
|
|
#!/usr/bin/env perl
|
2005-06-26 10:27:41 +00:00
|
|
|
BEGIN {
|
2008-01-15 22:03:59 +00:00
|
|
|
# add current source dir to the include-path
|
|
|
|
# we need this for make distcheck
|
|
|
|
(my $srcdir = $0) =~ s,/[^/]+$,/,;
|
|
|
|
unshift @INC, $srcdir;
|
2005-06-26 10:27:41 +00:00
|
|
|
}
|
2005-05-10 18:48:59 +00:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use IO::Socket;
|
2005-06-28 17:25:35 +00:00
|
|
|
use Test::More tests => 6;
|
2005-06-15 09:37:18 +00:00
|
|
|
use LightyTest;
|
2005-05-10 18:48:59 +00:00
|
|
|
|
2005-06-15 09:37:18 +00:00
|
|
|
my $tf_real = LightyTest->new();
|
|
|
|
my $tf_proxy = LightyTest->new();
|
2005-05-10 18:48:59 +00:00
|
|
|
|
2005-06-15 09:37:18 +00:00
|
|
|
my $t;
|
2005-05-10 18:48:59 +00:00
|
|
|
|
|
|
|
## we need two procs
|
|
|
|
## 1. the real webserver
|
|
|
|
## 2. the proxy server
|
|
|
|
|
2005-06-15 09:37:18 +00:00
|
|
|
$tf_real->{PORT} = 2048;
|
|
|
|
$tf_real->{CONFIGFILE} = 'lighttpd.conf';
|
|
|
|
|
|
|
|
$tf_proxy->{PORT} = 2050;
|
|
|
|
$tf_proxy->{CONFIGFILE} = 'proxy.conf';
|
|
|
|
|
|
|
|
ok($tf_real->start_proc == 0, "Starting lighttpd") or die();
|
2005-05-10 18:48:59 +00:00
|
|
|
|
2005-06-15 09:37:18 +00:00
|
|
|
ok($tf_proxy->start_proc == 0, "Starting lighttpd as proxy") or die();
|
2005-05-10 18:48:59 +00:00
|
|
|
|
2005-06-15 09:37:18 +00:00
|
|
|
$t->{REQUEST} = ( <<EOF
|
2005-08-17 09:52:16 +00:00
|
|
|
GET /index.html HTTP/1.0
|
2005-05-10 18:48:59 +00:00
|
|
|
Host: www.example.org
|
|
|
|
EOF
|
|
|
|
);
|
2005-08-31 12:55:44 +00:00
|
|
|
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
|
2005-06-15 09:37:18 +00:00
|
|
|
ok($tf_proxy->handle_http($t) == 0, 'valid request');
|
2005-05-10 18:48:59 +00:00
|
|
|
|
2005-06-28 17:25:35 +00:00
|
|
|
$t->{REQUEST} = ( <<EOF
|
2005-08-17 09:52:16 +00:00
|
|
|
GET /index.html HTTP/1.0
|
2005-06-28 17:25:35 +00:00
|
|
|
Host: www.example.org
|
|
|
|
EOF
|
|
|
|
);
|
2005-11-18 13:27:47 +00:00
|
|
|
$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Server' => 'Apache 1.3.29' } ];
|
2005-06-28 17:25:35 +00:00
|
|
|
ok($tf_proxy->handle_http($t) == 0, 'drop Server from real server');
|
|
|
|
|
2005-06-15 09:37:18 +00:00
|
|
|
ok($tf_proxy->stop_proc == 0, "Stopping lighttpd proxy");
|
2005-05-10 18:48:59 +00:00
|
|
|
|
2005-06-15 09:37:18 +00:00
|
|
|
ok($tf_real->stop_proc == 0, "Stopping lighttpd");
|