Apache-Module
view release on metacpan or search on metacpan
lib/Apache/ShowRequest.pm view on Meta::CPAN
if ($status != DECLINED && (!$run_all || $status != OK)) {
$say_defined = 1;
$format = sub { "<i>@_</i>" };
}
}
else {
print $format->("undef\n");
}
}
print "\n";
return $run_all ? OK : DECLINED;
}
sub invoke_handler {
my $r = shift;
my $content_type = $r->content_type ? $r->content_type : "text/plain";
my $handler = $r->handler ? $r->handler : $content_type;
my $top_module = Apache::Module->top_module;
print "Request phase: response handler (type: $handler)\n";
for (my $modp = $top_module; $modp; $modp = $modp->next) {
next unless $modp->handlers;
for (my $handp = $modp->handlers; $handp; $handp = $handp->next) {
next unless $handp->content_type;
my $name = $modp->name;
$name =~ s/\.c$//;
if ($handler eq $handp->content_type) {
#direct match
print_item($name, "defined\n");
#$handp->handler->($r);
}
else {
#wildcard match
my $type = $handp->content_type;
next unless $type =~ /\*/;
my $pat = "\Q$type";
$pat =~ s/\*/.*/g;
if($handler =~ /$pat/) {
print_item($name, "defined\n");
#$handp->handler->($r);
}
}
}
}
}
sub print_item {
my $name = shift;
print " $name ", '.' x (28 - length($name)), @_;
}
sub constant_name {
my $status = shift;
my $bold = ($status != OK) && ($status != DECLINED);
print "<b>" if $bold;
print Apache::Constants->name($status);
print "</b>" if $bold;
}
1;
__END__
=head1 NAME
Apache::ShowRequest - Show phases and module participation
=head1 SYNOPSIS
<Location /show>
SetHandler perl-script
PerlHandler Apache::ShowRequest
</Location>
=head1 DESCRIPTION
This module will run a request using the given B<PATH_INFO> as the uri.
Each request phase will be run in order, along with each module handler.
The module response code will be printed or B<undef> if the module does not
participate in the given phase. Apache::ShowRequest stops running module
handlers for the given phase just as Apache would. For example, if any
returns a code other than B<OK> or B<DECLINED>. Or, phases which only
allow one module to return B<OK>, e.g. URI translate.
The content response phase is not run, but possible modules are listed as
B<defined>.
=head1 AUTHOR
Doug MacEachern
=head1 SEE ALSO
Apache::Module(3), Apache(3), mod_perl(3)
( run in 0.752 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )