X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FEngine%2FCGI.pm;h=d04fea49ecace01f6d13033df65351423b1f1c97;hb=96d8d513f11c4fc078b4956a779a68f411cfbee6;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..d04fea4 100644 --- a/lib/Catalyst/Engine/CGI.pm +++ b/lib/Catalyst/Engine/CGI.pm @@ -1,10 +1,14 @@ package Catalyst::Engine::CGI; +use MRO::Compat; +use mro 'c3'; use Moose; extends 'Catalyst::Engine'; has env => (is => 'rw'); +no Moose; + =head1 NAME Catalyst::Engine::CGI - The CGI Engine @@ -41,7 +45,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"; } @@ -139,21 +143,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 +166,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 ); @@ -172,15 +176,14 @@ sub prepare_path { =cut -around prepare_query_parameters => sub { - my $orig = shift; +sub prepare_query_parameters { my ( $self, $c ) = @_; local (*ENV) = $self->env || \%ENV; if ( $ENV{QUERY_STRING} ) { - $self->$orig( $c, $ENV{QUERY_STRING} ); + $self->next::method( $c, $ENV{QUERY_STRING} ); } -}; +} =head2 $self->prepare_request($c, (env => \%env)) @@ -200,9 +203,10 @@ Enable autoflush on the output handle for CGI-based engines. =cut -before prepare_write => sub { +sub prepare_write { *STDOUT->autoflush(1); -}; + return shift->next::method(@_); +} =head2 $self->write($c, $buffer) @@ -210,8 +214,7 @@ Writes the buffer to the client. =cut -around write => sub { - my $orig = shift; +sub write { my ( $self, $c, $buffer ) = @_; # Prepend the headers if they have not yet been sent @@ -219,8 +222,8 @@ around write => sub { $buffer = $headers . $buffer; } - return $self->$orig( $c, $buffer ); -}; + return $self->next::method( $c, $buffer ); +} =head2 $self->read_chunk($c, $buffer, $length)