- allow multiple Catalyst apps to run on the same mod_perl instance
(not the same app!)
- fixed MP2 engines
- - removed apreq dependency from all MP engines.
+ - removed apreq dependency from all MP engines
+ - added support for MP registry scripts
+ - added support for LocationMatch and ScriptAliasMatch in MP engines
- added SpeedyCGI engine
5.10 Sat Apr 23 11:16:00 2005
use strict;
use base qw[Catalyst::Engine Catalyst::Engine::Apache];
+use File::Spec;
use URI;
use URI::http;
sub prepare_path {
my $c = shift;
- my $base;
+ {
+ my $path = $c->apache->uri;
+
+ if ( my $location = $c->apache->location ) {
+
+ if ( index( $path, $location ) == 0 ) {
+ $path = substr( $path, length($location) );
+ }
+ }
+
+ $path =~ s/^\///;
+
+ if ( my $filename = $c->apache->filename ) {
+
+ $filename = ( File::Spec->splitpath($filename) )[2];
+
+ if ( index( $path, $filename ) == 0 ) {
+ $path = substr( $path, length($filename) );
+ }
+ }
+
+ $path =~ s/^\///;
+
+ $c->request->path($path);
+ }
+
{
my $scheme = $c->request->secure ? 'https' : 'http';
my $host = $c->apache->hostname;
my $port = $c->apache->get_server_port;
- my $path = $c->apache->location || '/';
+ my $path = $c->apache->uri;
+ if ( length( $c->request->path ) ) {
+ $path =~ s/\/$//;
+ $path = substr( $path, 0, length($path) - length($c->req->path) );
+ }
+
unless ( $path =~ /\/$/ ) {
$path .= '/';
}
- $base = URI->new;
+ my $base = URI->new;
$base->scheme($scheme);
$base->host($host);
$base->port($port);
$base->path($path);
-
- $base = $base->canonical->as_string;
+
+ $c->request->base( $base->canonical->as_string );
}
-
- my $location = $c->apache->location || '/';
- my $path = $c->apache->uri || '/';
- $path =~ s/^($location)?\///;
- $path =~ s/^\///;
-
- $c->req->base($base);
- $c->req->path($path);
}
=item $c->prepare_request($r)
=cut
-sub run { }
+sub run { shift->handler(@_) }
=back
=cut
-sub prepare_body {
+sub prepare_body {
shift->Catalyst::Engine::CGI::prepare_body(@_);
}
=cut
-sub prepare_parameters {
+sub prepare_parameters {
shift->Catalyst::Engine::CGI::prepare_parameters(@_);
}
sub prepare_request {
my ( $c, $r, @arguments ) = @_;
-
- $ENV{CONTENT_TYPE} = $r->header_in("Content-Type");
- $ENV{CONTENT_LENGTH} = $r->header_in("Content-Length");
- $ENV{QUERY_STRING} = $r->args;
- $ENV{REQUEST_METHOD} = $r->method;
+
+ unless ( $ENV{REQUEST_METHOD} ) {
+
+ $ENV{CONTENT_TYPE} = $r->header_in("Content-Type");
+ $ENV{CONTENT_LENGTH} = $r->header_in("Content-Length");
+ $ENV{QUERY_STRING} = $r->args;
+ $ENV{REQUEST_METHOD} = $r->method;
+
+ my $cleanup = sub {
+ delete( $ENV{$_} ) for qw( CONTENT_TYPE
+ CONTENT_LENGTH
+ QUERY_STRING
+ REQUEST_METHOD );
+ };
+
+ $r->register_cleanup($cleanup);
+ }
$c->SUPER::prepare_request($r);
$c->Catalyst::Engine::CGI::prepare_request( $r, @arguments );
=cut
-sub prepare_uploads {
+sub prepare_uploads {
shift->Catalyst::Engine::CGI::prepare_uploads(@_);
}
=cut
-sub prepare_body {
+sub prepare_body {
shift->Catalyst::Engine::CGI::prepare_body(@_);
}
=cut
-sub prepare_parameters {
+sub prepare_parameters {
shift->Catalyst::Engine::CGI::prepare_parameters(@_);
}
sub prepare_request {
my ( $c, $r, @arguments ) = @_;
-
- $ENV{CONTENT_TYPE} = $r->headers_in->get("Content-Type");
- $ENV{CONTENT_LENGTH} = $r->headers_in->get("Content-Length");
- $ENV{QUERY_STRING} = $r->args;
- $ENV{REQUEST_METHOD} = $r->method;
+
+ unless ( $ENV{REQUEST_METHOD} ) {
+
+ $ENV{CONTENT_TYPE} = $r->headers_in->get("Content-Type");
+ $ENV{CONTENT_LENGTH} = $r->headers_in->get("Content-Length");
+ $ENV{QUERY_STRING} = $r->args;
+ $ENV{REQUEST_METHOD} = $r->method;
+
+ my $cleanup = sub {
+ delete( $ENV{$_} ) for qw( CONTENT_TYPE
+ CONTENT_LENGTH
+ QUERY_STRING
+ REQUEST_METHOD );
+ };
+
+ $r->pool->cleanup_register($cleanup);
+ }
$c->SUPER::prepare_request($r);
$c->Catalyst::Engine::CGI::prepare_request( $r, @arguments );
=cut
-sub prepare_uploads {
+sub prepare_uploads {
shift->Catalyst::Engine::CGI::prepare_uploads(@_);
}
=cut
-sub prepare_body {
+sub prepare_body {
shift->Catalyst::Engine::CGI::prepare_body(@_);
}
=cut
-sub prepare_parameters {
+sub prepare_parameters {
shift->Catalyst::Engine::CGI::prepare_parameters(@_);
}
sub prepare_request {
my ( $c, $r, @arguments ) = @_;
- $ENV{CONTENT_TYPE} = $r->headers_in->get("Content-Type");
- $ENV{CONTENT_LENGTH} = $r->headers_in->get("Content-Length");
- $ENV{QUERY_STRING} = $r->args;
- $ENV{REQUEST_METHOD} = $r->method;
+ unless ( $ENV{REQUEST_METHOD} ) {
+
+ $ENV{CONTENT_TYPE} = $r->headers_in->get("Content-Type");
+ $ENV{CONTENT_LENGTH} = $r->headers_in->get("Content-Length");
+ $ENV{QUERY_STRING} = $r->args;
+ $ENV{REQUEST_METHOD} = $r->method;
+
+ my $cleanup = sub {
+ delete( $ENV{$_} ) for qw( CONTENT_TYPE
+ CONTENT_LENGTH
+ QUERY_STRING
+ REQUEST_METHOD );
+ };
+
+ $r->pool->cleanup_register($cleanup);
+ }
$c->SUPER::prepare_request($r);
$c->Catalyst::Engine::CGI::prepare_request( $r, @arguments );
=cut
-sub prepare_uploads {
+sub prepare_uploads {
shift->Catalyst::Engine::CGI::prepare_uploads(@_);
}
=cut
-sub run { shift->handler }
+sub run { shift->handler(@_) }
=back