#!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',
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' );