use NEXT;
use URI;
+my $uri_proto=URI->new();
__PACKAGE__->mk_accessors('env');
=head1 NAME
$c->response->header( Status => $c->response->status );
- print $c->response->headers->as_string("\015\012");
- print "\015\012";
+ print $c->response->headers->as_string("\015\012") . "\015\012";
}
=head2 $self->prepare_connection($c)
local (*ENV) = $self->env || \%ENV;
# Read headers from %ENV
- while ( my ( $header, $value ) = each %ENV ) {
+ foreach my $header ( keys %ENV ) {
next unless $header =~ /^(?:HTTP|CONTENT|COOKIE)/i;
( my $field = $header ) =~ s/^HTTPS?_//;
- $c->req->headers->header( $field => $value );
+ $c->req->headers->header( $field => $ENV{$header} );
}
}
local (*ENV) = $self->env || \%ENV;
my $scheme = $c->request->secure ? 'https' : 'http';
- my $host = $ENV{HTTP_HOST} || $ENV{SERVER_NAME};
- my $port = $ENV{SERVER_PORT} || 80;
- my $base_path = $ENV{REDIRECT_URL} || $ENV{SCRIPT_NAME} || '/';
+ my $host = $ENV{HTTP_HOST} || $ENV{SERVER_NAME};
+ my $port = $ENV{SERVER_PORT} || 80;
+ my $base_path;
+ if ( exists $ENV{REDIRECT_URL} ) {
+ $base_path = $ENV{REDIRECT_URL};
+ $base_path =~ s/$ENV{PATH_INFO}$//;
+ }
+ else {
+ $base_path = $ENV{SCRIPT_NAME} || '/';
+ }
# If we are running as a backend proxy, get the true hostname
PROXY_CHECK:
$port = $c->request->secure ? 443 : 80;
}
- my $path = $base_path . $ENV{PATH_INFO};
+ # set the base URI
+ # base must end in a slash
+ $base_path .= '/' unless ( $base_path =~ /\/$/ );
+
+ my $path = $base_path . ( $ENV{PATH_INFO} || '' );
$path =~ s{^/+}{};
- my $uri = URI->new;
+ my $uri = $uri_proto->clone;
$uri->scheme($scheme);
$uri->host($host);
$uri->port($port);
# sanitize the URI
$uri = $uri->canonical;
$c->request->uri($uri);
-
- # set the base URI
- # base must end in a slash
- $base_path .= '/' unless ( $base_path =~ /\/$/ );
my $base = $uri->clone;
$base->path_query($base_path);
$c->request->base($base);