1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#!/usr/local/bin/perl -w
#
# Check GET via HTTP.
#
my $num_tests = 9;
my(@test_scripts) = qw(test perl-status);
%get_only = map { $_,1 } qw(perl-status);
if($] > 5.003) {
$num_tests += 3;
push @test_scripts, qw(io/perlio.pl);
}
print "1..$num_tests\n";
use Apache::test;
require LWP::UserAgent;
my $ua = new LWP::UserAgent; # create a useragent to test
my($request,$response,$str);
foreach $s (@test_scripts) {
$netloc = $net::httpserver;
$script = $PERL_DIR . "/$s";
$url = new URI::URL("http://$netloc$script?query");
$request = new HTTP::Request('GET', $url);
print "GET $url\n\n";
$response = $ua->request($request, undef, undef);
$str = $response->as_string;
print "$str\n";
die "$1\n" if $str =~ /(Internal Server Error)/;
test ++$i, ($response->is_success);
next if $get_only{$s};
test ++$i, ($str =~ /^REQUEST_METHOD=GET$/m);
test ++$i, ($str =~ /^QUERY_STRING=query$/m);
}
test ++$i, $response->header("Server") =~ /mod_perl/;
print "Server: ", $response->header("Server"), "\n";
#test PerlSetupEnv Off
test ++$i, fetch("$PERL_DIR/noenv/test.pl") !~ /SERVER_SOFTWARE/m;
print "pounding a bit...\n";
for (1..3) {
test ++$i, ($ua->request($request, undef, undef)->is_success);
}
# avoid -w warning
$dummy = $net::httpserver;
$dummy = $net::perldir;
|