From: NoFixedAbode Date: Fri, 4 Dec 2009 16:26:08 +0000 (+0000) Subject: setup now concatenates its environment to %ENV instead of replacing it X-Git-Tag: v1.1~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FHTTP-Request-AsCGI.git;a=commitdiff_plain;h=15e50838be5818e7419ed569dd376994d04c5c67 setup now concatenates its environment to %ENV instead of replacing it --- diff --git a/Changes b/Changes index 5a5b8bc..bb5d7de 100644 --- a/Changes +++ b/Changes @@ -1,11 +1,10 @@ This file documents the revision history for Perl extension HTTP::Request::AsCGI. -1.0 2009-12-03 - - added test to check that $ENV is preserved after setup is called - 1.0 2009-11-30 - Change how PATH_INFO is decoded so that everything is decoded, including URI reserved characters (RT#50082) + - added test to check that %ENV is preserved after setup is called + - setup now concatenates its environment to %ENV instead of replacing it 0.9 2009-04-27 - unescape PATH_INFO more safely diff --git a/lib/HTTP/Request/AsCGI.pm b/lib/HTTP/Request/AsCGI.pm index e5e167f..c12e8f6 100644 --- a/lib/HTTP/Request/AsCGI.pm +++ b/lib/HTTP/Request/AsCGI.pm @@ -156,7 +156,7 @@ sub setup { { no warnings 'uninitialized'; - %ENV = %{ $self->environment }; + %ENV = %ENV, %{ $self->environment }; } if ( $INC{'CGI.pm'} ) { @@ -181,7 +181,7 @@ sub response { $headers .= $line; last if $headers =~ /\x0d?\x0a\x0d?\x0a$/; } - + unless ( defined $headers ) { $headers = "HTTP/1.1 500 Internal Server Error\x0d\x0a"; } @@ -208,7 +208,7 @@ sub response { $response->code($code); $response->message($message); } - + my $length = ( stat( $self->stdout ) )[7] - tell( $self->stdout ); if ( $response->code == 500 && !$length ) { @@ -306,36 +306,36 @@ __END__ use CGI; use HTTP::Request; use HTTP::Request::AsCGI; - + my $request = HTTP::Request->new( GET => 'http://www.host.com/' ); my $stdout; - + { my $c = HTTP::Request::AsCGI->new($request)->setup; my $q = CGI->new; - + print $q->header, $q->start_html('Hello World'), $q->h1('Hello World'), $q->end_html; - + $stdout = $c->stdout; - + # environment and descriptors will automatically be restored # when $c is destructed. } - + while ( my $line = $stdout->getline ) { print $line; } - + =head1 DESCRIPTION Provides a convenient way of setting up an CGI environment from an HTTP::Request. =head1 METHODS -=over 4 +=over 4 =item new ( $request [, key => value ] ) @@ -344,7 +344,7 @@ by optional pairs of environment key and value. =item environment -Returns a hashref containing the environment that will be used in setup. +Returns a hashref containing the environment that will be used in setup. Changing the hashref after setup has been called will have no effect. =item setup