X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F05env.t;h=0c31b5cd1f5afbf1adc579bb4241025e49a50537;hb=HEAD;hp=1e9d6661dd0d4f7734cda80a9d9fef1465e59d66;hpb=8596f5a59563453e81ca41c0e6dfea3f52354ae0;p=catagits%2FHTTP-Request-AsCGI.git diff --git a/t/05env.t b/t/05env.t index 1e9d666..0c31b5c 100644 --- a/t/05env.t +++ b/t/05env.t @@ -1,14 +1,24 @@ #!perl -use Test::More tests => 10; +use Test::More; use strict; use warnings; +BEGIN { + eval { require Encode } + or plan skip_all => 'This test requires Encode'; +} + use HTTP::Request; use HTTP::Request::AsCGI; use Encode; +plan tests => 11; + +local %ENV; +$ENV{__PRESERVE_ENV_TEST} = 1; + my $r = HTTP::Request->new( GET => 'http://www.host.com/cgi-bin/script.cgi/my%20path%2F?a=1&b=2', [ 'X-Test' => 'Test' ] ); my %e = ( SCRIPT_NAME => '/cgi-bin/script.cgi', @@ -24,13 +34,15 @@ $c->setup; is( $ENV{GATEWAY_INTERFACE}, 'CGI/1.1', 'GATEWAY_INTERFACE' ); is( $ENV{HTTP_HOST}, 'www.host.com:80', 'HTTP_HOST' ); is( $ENV{HTTP_X_TEST}, 'Test', 'HTTP_X_TEST' ); -is( decode('UTF-8', $ENV{PATH_INFO}), '/foo%2FБЯ陰茎', 'PATH_INFO'); +is( decode('UTF-8', $ENV{PATH_INFO}), '/foo/БЯ陰茎', 'PATH_INFO'); is( $ENV{QUERY_STRING}, 'a=1&b=2', 'QUERY_STRING' ); is( $ENV{SCRIPT_NAME}, '/cgi-bin/script.cgi', 'SCRIPT_NAME' ); is( $ENV{REQUEST_METHOD}, 'GET', 'REQUEST_METHOD' ); is( $ENV{SERVER_NAME}, 'www.host.com', 'SERVER_NAME' ); is( $ENV{SERVER_PORT}, '80', 'SERVER_PORT' ); +is( $ENV{__PRESERVE_ENV_TEST}, 1, 'PRESERVE_ENV' ); + $c->restore; is( $ENV{GATEWAY_INTERFACE}, undef, 'No CGI env after restore' );