X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FCGI.pm;h=5f930eddf0dedc87e94a75d8acc02852f0b49258;hb=cfc303c8cbb9daad5dad8e7c9d09a35b8cfa7c8e;hp=e94452644945a8b1be7d910fee2b91d6b22033e3;hpb=0556eb49954590b794221ed3a033565c85dbeb32;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine/CGI.pm b/lib/Catalyst/Engine/CGI.pm index e944526..5f930ed 100644 --- a/lib/Catalyst/Engine/CGI.pm +++ b/lib/Catalyst/Engine/CGI.pm @@ -75,7 +75,7 @@ This class overloads some methods from C. sub finalize_headers { my $c = shift; - my %headers = ( -nph => 1 ); + my %headers; $headers{-status} = $c->response->status if $c->response->status; for my $name ( $c->response->headers->header_field_names ) { $headers{"-$name"} = $c->response->headers->header($name); @@ -135,6 +135,8 @@ sub prepare_headers { ( my $field = $header ) =~ s/^HTTPS?_//; $c->req->headers->header( $field => $c->cgi->http($header) ); } + $c->req->headers->header( 'Content-Type' => $c->cgi->content_type ); + $c->req->headers->header( 'Content-Length' => $c->cgi->content_length ); } =item $c->prepare_parameters @@ -157,19 +159,28 @@ sub prepare_parameters { sub prepare_path { my $c = shift; - $c->req->path( $c->cgi->url( -absolute => 1, -path_info => 1 ) ); - my $loc = $c->cgi->url( -absolute => 1 ); - no warnings 'uninitialized'; - $c->req->{path} =~ s/^($loc)?\///; - $c->req->{path} .= '/' if $c->req->path eq $loc; - my $base = $c->cgi->url; - if ( $ENV{CATALYST_TEST} ) { - my $script = $c->cgi->script_name; - $base =~ s/$script$//i; + + my $base; + { + my $scheme = $ENV{HTTPS} ? 'https' : 'http'; + my $host = $ENV{HTTP_HOST} || $ENV{SERVER_NAME}; + my $port = $ENV{SERVER_PORT} || 80; + my $path = $ENV{SCRIPT_NAME} || '/'; + + $base = URI->new; + $base->scheme($scheme); + $base->host($host); + $base->port($port); + $base->path($path); + + $base = $base->canonical->as_string; } - $base = URI->new($base); - $base->path('/') if ( $ENV{CATALYST_TEST} || !$base->path ); - $c->req->base( $base->as_string ); + + my $path = $ENV{PATH_INFO} || '/'; + $path =~ s/^\///; + + $c->req->base($base); + $c->req->path($path); } =item $c->prepare_request @@ -185,6 +196,7 @@ sub prepare_request { shift->cgi( CGI::Simple->new ) } sub prepare_uploads { my $c = shift; for my $name ( $c->cgi->upload ) { + next unless defined $name; $c->req->uploads->{$name} = { fh => $c->cgi->upload($name), size => $c->cgi->upload_info( $name, 'size' ),