From: Andy Grundman Date: Tue, 15 Nov 2005 14:50:04 +0000 (+0000) Subject: Fixed FastCGI engine to not clobber the global %ENV on each request (Sam Vilain) X-Git-Tag: 5.7099_04~915 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=84528885db9fca49c55d5859e275b70ec1a3ea28;hp=b39840dab69d787e608212d070f7ab4a29204f5f Fixed FastCGI engine to not clobber the global %ENV on each request (Sam Vilain) --- diff --git a/Changes b/Changes index ff8f7e1..6721e00 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ This file documents the revision history for Perl extension Catalyst. +5.56 + - Fixed FastCGI engine to not clobber the global %ENV on each + request. (Sam Vilain) + 5.55 2005-11-15 12:55:00 - Fixed multiple cookie handling diff --git a/lib/Catalyst/Engine/CGI.pm b/lib/Catalyst/Engine/CGI.pm index 950cc2d..741816e 100644 --- a/lib/Catalyst/Engine/CGI.pm +++ b/lib/Catalyst/Engine/CGI.pm @@ -5,6 +5,8 @@ use base 'Catalyst::Engine'; use NEXT; use URI; +__PACKAGE__->mk_accessors( 'env' ); + =head1 NAME Catalyst::Engine::CGI - The CGI Engine @@ -53,6 +55,7 @@ sub finalize_headers { sub prepare_connection { my ( $self, $c ) = @_; + local(*ENV) = $self->env || \%ENV; $c->request->address( $ENV{REMOTE_ADDR} ); @@ -90,6 +93,7 @@ sub prepare_connection { sub prepare_headers { my ( $self, $c ) = @_; + local(*ENV) = $self->env || \%ENV; # Read headers from %ENV while ( my ( $header, $value ) = each %ENV ) { @@ -105,6 +109,7 @@ sub prepare_headers { sub prepare_path { my ( $self, $c ) = @_; + local(*ENV) = $self->env || \%ENV; my $scheme = $c->request->secure ? 'https' : 'http'; my $host = $ENV{HTTP_HOST} || $ENV{SERVER_NAME}; @@ -155,12 +160,25 @@ sub prepare_path { sub prepare_query_parameters { my ( $self, $c ) = @_; + local(*ENV) = $self->env || \%ENV; if ( $ENV{QUERY_STRING} ) { $self->SUPER::prepare_query_parameters( $c, $ENV{QUERY_STRING} ); } } +=item $self->prepare_request($c, (env => \%env)) + +=cut + +sub prepare_request { + my ( $self, $c, %args ) = @_; + + if ( $args{env} ) { + $self->env( $args{env} ); + } +} + =item $self->prepare_write($c) Enable autoflush on the output handle for CGI-based engines. diff --git a/lib/Catalyst/Engine/FastCGI.pm b/lib/Catalyst/Engine/FastCGI.pm index d832bea..4ff269e 100644 --- a/lib/Catalyst/Engine/FastCGI.pm +++ b/lib/Catalyst/Engine/FastCGI.pm @@ -61,9 +61,11 @@ sub run { } $options ||= {}; + + my %env; my $request = - FCGI::Request( \*STDIN, \*STDOUT, \*STDERR, \%ENV, $sock, + FCGI::Request( \*STDIN, \*STDOUT, \*STDERR, \%env, $sock, ( $options->{nointr} ? 0 : &FCGI::FAIL_ACCEPT_ON_INTR ), ); @@ -78,7 +80,7 @@ sub run { while ( $request->Accept >= 0 ) { $proc_manager && $proc_manager->pm_pre_dispatch(); - $class->handle_request; + $class->handle_request( env => \%env ); $proc_manager && $proc_manager->pm_pre_dispatch(); } }