X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FCGI.pm;h=2c2fc87584373f6fe449f557958fa976082304d3;hb=8fc0d39e47032a9b28be3a70b2042576918cadcc;hp=75b8fba0a6b97717a416fcd80521cbd36247e7ef;hpb=7fa2c9c1b85c98786655ad5169708d8dc84e8353;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Engine/CGI.pm b/lib/Catalyst/Engine/CGI.pm index 75b8fba..2c2fc87 100644 --- a/lib/Catalyst/Engine/CGI.pm +++ b/lib/Catalyst/Engine/CGI.pm @@ -41,7 +41,7 @@ sub finalize_headers { $c->response->header( Status => $c->response->status ); - $self->{_header_buf} + $self->{_header_buf} = $c->response->headers->as_string("\015\012") . "\015\012"; } @@ -70,7 +70,7 @@ sub prepare_connection { $request->address($ip); } - $request->hostname( $ENV{REMOTE_HOST} ); + $request->hostname( $ENV{REMOTE_HOST} ) if exists $ENV{REMOTE_HOST}; $request->protocol( $ENV{SERVER_PROTOCOL} ); $request->user( $ENV{REMOTE_USER} ); $request->method( $ENV{REQUEST_METHOD} ); @@ -139,21 +139,21 @@ sub prepare_path { # set the request URI my $path = $base_path . ( $ENV{PATH_INFO} || '' ); $path =~ s{^/+}{}; - + # Using URI directly is way too slow, so we construct the URLs manually my $uri_class = "URI::$scheme"; - + # HTTP_HOST will include the port even if it's 80/443 $host =~ s/:(?:80|443)$//; - + if ( $port !~ /^(?:80|443)$/ && $host !~ /:/ ) { $host .= ":$port"; } - + # Escape the path $path =~ s/([^$URI::uric])/$URI::Escape::escapes{$1}/go; $path =~ s/\?/%3F/g; # STUPID STUPID SPECIAL CASE - + my $query = $ENV{QUERY_STRING} ? '?' . $ENV{QUERY_STRING} : ''; my $uri = $scheme . '://' . $host . '/' . $path . $query; @@ -162,7 +162,7 @@ sub prepare_path { # set the base URI # base must end in a slash $base_path .= '/' unless $base_path =~ m{/$}; - + my $base_uri = $scheme . '://' . $host . $base_path; $c->request->base( bless \$base_uri, $uri_class ); @@ -200,8 +200,9 @@ Enable autoflush on the output handle for CGI-based engines. =cut -before prepare_write => sub { +around prepare_write => sub { *STDOUT->autoflush(1); + return shift->(@_); }; =head2 $self->write($c, $buffer) @@ -236,15 +237,11 @@ sub run { shift; shift->handle_request(@_) } =head1 SEE ALSO -L L. +L, L =head1 AUTHORS -Sebastian Riedel, - -Christian Hansen, - -Andy Grundman, +Catalyst Contributors, see Catalyst.pm =head1 COPYRIGHT @@ -252,5 +249,6 @@ This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. =cut +no Moose; 1;