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
|
# please insert nothing before this line: -*- mode: cperl; cperl-indent-level: 4; cperl-continued-statement-offset: 4; indent-tabs-mode: nil -*-
package TestApache::cgihandler;
use strict;
use warnings FATAL => 'all';
use Apache2::RequestRec ();
use APR::Table ();
use Apache2::Const -compile => qw(OK M_POST);
#test the 1.x style perl-script handler
sub handler {
my $r = shift;
$ENV{FOO} = 2;
if ($r->method_number == Apache2::Const::M_POST) {
my $cl = $r->headers_in->get('content-length');
my $buff;
#XXX: working around a bug in ithreads Perl
#that would cause modules/cgi #3 to fail
# read STDIN, $buff, $cl;
read 'STDIN', $buff, $cl;
print $buff;
}
else {
print "1..3\n";
print "ok 1\n", "ok ", "$ENV{FOO}\n";
#XXX: current implementation of tie %ENV to $r->subprocess_env
# is not threadsafe
# my $foo = $r->subprocess_env->get('FOO');
my $foo = $ENV{FOO};
$foo++;
print "ok $foo\n";
}
Apache2::Const::OK;
}
1;
__END__
SetHandler perl-script
PerlResponseHandler TestApache::cgihandler
|