X-Git-Url: http://git.shiar.net/perl/plp/.git/blobdiff_plain/6fc33d2b5bd84a3bfb1c8d393cf57e1081fcd623..65a8aed85aa78407018da99ab616f632f40a8eb9:/PLP/Apache.pm diff --git a/PLP/Apache.pm b/PLP/Apache.pm index 217546f..c388095 100644 --- a/PLP/Apache.pm +++ b/PLP/Apache.pm @@ -4,6 +4,23 @@ use strict; our $VERSION = '1.00'; +use PLP; + +use constant MP2 => ( + defined $ENV{MOD_PERL_API_VERSION} and $ENV{MOD_PERL_API_VERSION} >= 2 +); + +BEGIN { + if (MP2) { + require Apache2::Const; + require Apache2::RequestRec; + require Apache2::RequestUtil; + require Apache2::RequestIO; + } else { + require Apache::Constants; + } +} + # mod_perl initializer: returns 0 on success, Apache error code on failure sub init { our $r = shift; @@ -13,10 +30,10 @@ sub init { $ENV{PLP_FILENAME} = my $filename = $r->filename; unless (-f $filename) { - return Apache::Constants::NOT_FOUND(); + return MP2 ? Apache2::Const::HTTP_NOT_FOUND() : Apache::Constants::NOT_FOUND(); } unless (-r _) { - return Apache::Constants::FORBIDDEN(); + return MP2 ? Apache2::Const::HTTP_FORBIDDEN() : Apache::Constants::FORBIDDEN(); } $ENV{PLP_NAME} = $r->uri; @@ -39,5 +56,17 @@ sub print { $PLP::Apache::r->print(@_); } +# This is the mod_perl handler. +sub handler { + PLP::clean(); + if (my $ret = init($_[0])) { + return $ret; + } + #S PLP::start($_[0]); + PLP::start(); + no strict 'subs'; + return MP2 ? Apache2::Const::OK() : Apache::Constants::OK(); +} + 1;