X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FApache%2FBase.pm;h=ebb31486214a80bda66ad872c646cced60e0a844;hb=b77e7869b55e0d2df5aaa3a37ad2cca9c0989abc;hp=d40f0509681f0ae73cf53f4a6a50131b89648a7f;hpb=66294129a6520edc031aa7a43fc9bdfce669af15;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine/Apache/Base.pm b/lib/Catalyst/Engine/Apache/Base.pm index d40f050..ebb3148 100644 --- a/lib/Catalyst/Engine/Apache/Base.pm +++ b/lib/Catalyst/Engine/Apache/Base.pm @@ -3,6 +3,7 @@ package Catalyst::Engine::Apache::Base; use strict; use base qw[Catalyst::Engine Catalyst::Engine::Apache]; +use File::Spec; use URI; use URI::http; @@ -77,7 +78,11 @@ sub prepare_connection { $c->request->protocol( $c->apache->protocol ); $c->request->user( $c->apache->user ); - if ( $ENV{HTTPS} || $c->apache->get_server_port == 443 ) { + if ( $ENV{HTTPS} && uc( $ENV{HTTPS} ) eq 'ON' ) { + $c->request->secure(1); + } + + if ( $c->apache->get_server_port == 443 ) { $c->request->secure(1); } } @@ -100,34 +105,56 @@ sub prepare_headers { # not directive 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 ( $c->apache->filename && -f $c->apache->filename && -x _ ) { + + my $filename = ( File::Spec->splitpath( $c->apache->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) @@ -143,7 +170,7 @@ sub prepare_request { =cut -sub run { } +sub run { shift->handler(@_) } =back