my
$tests
= 0;
my
$r
= Apache->request;
$r
->content_type(
"text/html"
);
$r
->send_http_header;
my
$doc_root
=
$r
->document_root;
my
$ht_access
=
"$doc_root/.htaccess"
;
my
$hooks_file
=
"$doc_root/hooks.txt"
;
sub
wipe_file {
local
*FH
;
open
FH,
">$_[0]"
;
print
FH
" "
;
close
FH;
}
for
(
$ht_access
,
$hooks_file
) {
wipe_file(
$_
);
}
local
*FH
;
if
(Apache::perl_hook(
"Authen"
)) {
open
FH,
">$ht_access"
;
print
FH
<<EOF;
AuthType Basic
AuthName mod_perl_tests
<Limit GET>
require valid-user
</Limit>
EOF
close
FH;
}
my
(
$hook
,
$package
,
$retval
);
for
(
qw(Access Authen Authz Fixup
HeaderParser Init Log Type Trans)
) {
next
unless
Apache::perl_hook(
$_
);
$tests
++;
$retval
= -1;
$hook
=
"Perl${_}Handler"
;
$package
=
$hook
;
unless
(
$_
eq
"Trans"
) {
$retval
= 0;
open
FH,
">>$ht_access"
or
die
"can't open $ht_access"
;
print
FH
"$hook $package\n"
;
close
FH;
}
undef
&{
"$package\:\:handler"
};
eval
<<"PACKAGE";
package $package;
sub $package\:\:handler {
my(\$r) = \@_;
return -1 unless \$r->is_main;
open FH, ">>$hooks_file" or die "can't open $hooks_file";
print FH "$hook ok\n";
close FH;
return $retval;
}
PACKAGE
$r
->
print
($@)
if
$@;
}
if
(
$My::config_is_perl
) {
$tests
--;
}
$r
->
print
(
$tests
);