X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FApache%2FMVC.pm;h=db2bbed641fec4f064b405764f518b6ba4f7cd3f;hb=8ca69904b2ec6ca0e6ae8677fff6bb7283b20d13;hp=dea64fffa161648d0cf4abb0c19b523c461e78f6;hpb=88403615773aa8c4a86006b5d41577e586d1c0ec;p=maypole.git diff --git a/lib/Apache/MVC.pm b/lib/Apache/MVC.pm index dea64ff..db2bbed 100644 --- a/lib/Apache/MVC.pm +++ b/lib/Apache/MVC.pm @@ -1,6 +1,6 @@ package Apache::MVC; -our $VERSION = '2.11'; +our $VERSION = '2.121'; use strict; use warnings; @@ -27,6 +27,7 @@ BEGIN { } require Apache2::RequestIO; require Apache2::RequestRec; + use Apache2::Log; require Apache2::RequestUtil; eval 'use Apache2::Const -compile => qw/REDIRECT/;'; # -compile 4 no import require APR::URI; @@ -93,11 +94,17 @@ functionality. See L for these: sub get_request { my ($self, $r) = @_; + my $request_options = $self->config->request_options || {}; my $ar; if ($MODPERL2) { - $ar = eval {require Apache2::Request} ? Apache2::Request->new($r) : $r; - } - else { $ar = Apache::Request->instance($r); } + $ar = eval {require Apache2::Request} ? Apache2::Request->new($r,%{$request_options}) : $r; + } else { + if (keys %$request_options) { + $ar = Apache::Request->new($r,%{$request_options}); + } else { + $ar = Apache::Request->instance($r); + } + } $self->ar($ar); } @@ -110,9 +117,15 @@ sub warn { my ($package, $line) = (caller)[0,2]; my $ar = $self->parent ? $self->parent->{ar} : $self->{ar}; if ( $args[0] and ref $self ) { + my @lines = split /\n/, (join '', @args); + $ar->warn("[$package line $line] ".shift(@lines)); + foreach(@lines) { + next unless $_; + $ar->warn(" $_"); + } $ar->warn("[$package line $line] ", @args) ; } else { - print "warn called by ", caller, " with ", @_, "\n"; + print STDERR "warn called by ", caller, " with ", @_, "\n"; } return; } @@ -191,8 +204,7 @@ can only be combined with status. sub redirect_request { my $r = shift; my $redirect_url = $_[0]; - my $status = $MODPERL2 ? eval 'Apache2::Const::REDIRECT;' : - eval 'Apache::Constants::REDIRECT;'; # why have to eval this? + my $status = $MODPERL2 ? eval 'Apache2::Const::REDIRECT;' : eval 'Apache::Constants::REDIRECT;'; if ($_[1]) { my %args = @_; if ($args{url}) { @@ -212,6 +224,7 @@ sub redirect_request { $r->ar->status($status); $r->ar->headers_out->set('Location' => $redirect_url); + $r->output('redirecting...

redirecting..

') unless ($r->output); return OK; }