our $MODPERL2;
our $modperl_version;
+# pjs -- fixed to use standard way from perl.apache.org
BEGIN {
- eval 'use Apache;';
- if ($@) {
- eval 'use mod_perl2; $modperl_version = $mod_perl2::VERSION; ';
- if ($@) {
- $modperl_version = $Apache2::RequestRec::VERSION;
- }
- require Apache2::RequestIO;
- require Apache2::RequestRec;
- require Apache2::RequestUtil;
- require APR::URI;
- require HTTP::Body;
- $MODPERL2 = 1;
+ #eval 'use Apache;'; # could fuck shit up if you have some file na
+ # named Apache.pm in your path forex CGI/Apache.pm
+ $MODPERL2 = ( exists $ENV{MOD_PERL_API_VERSION} and
+ $ENV{MOD_PERL_API_VERSION} >= 2 );
+ if ($MODPERL2) {
+ eval 'use mod_perl2; $modperl_version = $mod_perl2::VERSION;';
+ if ($@) {
+ $modperl_version = $Apache2::RequestRec::VERSION;
+ }
+ require Apache2::RequestIO;
+ require Apache2::RequestRec;
+ require Apache2::RequestUtil;
+ eval 'use Apache2::Const -compile => qw/REDIRECT/;'; # -compile 4 no import
+ require APR::URI;
+ require HTTP::Body;
} else {
- eval ' use mod_perl; ';
- require Apache;
- require Apache::Request;
- $MODPERL2 = 0;
- $modperl_version = 1;
+ eval ' use mod_perl; ';
+ require Apache;
+ require Apache::Request;
+ eval 'use Apache::Constants -compile => qw/REDIRECT/;';
+ $modperl_version = 1;
}
}
+
+
=head1 NAME
Apache::MVC - Apache front-end to Maypole
=cut
# FIXME: use headers_in to gather host and other information?
-sub redirect_request
+# pjs 4-7-06 fixed so it works but did not fix headers_in issue
+sub redirect_request
{
my $r = shift;
my $redirect_url = $_[0];
- my $status = "302";
+ my $status = $MODPERL2 ? eval 'Apache2::Const::REDIRECT;' :
+ eval 'Apache::Constants::REDIRECT;'; # why have to eval this?
if ($_[1]) {
my %args = @_;
if ($args{url}) {
$status = $args{status} if ($args{status});
}
- $r->headers_out->set('Status' => $status);
- $r->headers_out->set('Location' => $redirect_url);
+ $r->ar->status($status);
+ $r->ar->headers_out->set('Location' => $redirect_url);
+ #$r->output("");
return OK;
}