7 use Test::More tests => 7;
13 # http() without arguments should not cause warnings
14 local $SIG{__WARN__} = sub { die @_ };
15 ok eval { $cgi->http(); 1 }, "http() without arguments doesn't warn";
16 ok eval { $cgi->https(); 1 }, "https() without arguments doesn't warn";
20 # Capitalization and the use of hyphens versus underscores are not significant.
21 local $ENV{'HTTP_HOST'} = 'foo';
22 is $cgi->http('Host'), 'foo', 'http("Host") returns $ENV{HTTP_HOST}';
23 is $cgi->http('http-host'), 'foo', 'http("http-host") returns $ENV{HTTP_HOST}';
27 # Called with no arguments returns the list of HTTP environment variables
28 local $ENV{'HTTPS_FOO'} = 'bar';
29 my @http = $cgi->http();
30 is scalar( grep /^HTTPS/, @http), 0, "http() doesn't return HTTPS variables";
35 # The same as http(), but operates on the HTTPS environment variables present when the SSL protocol is in
36 # effect. Can be used to determine whether SSL is turned on.
37 my @expect = grep /^HTTPS/, keys %ENV;
38 push @expect, 'HTTPS' if not exists $ENV{HTTPS};
39 push @expect, 'HTTPS_KEYSIZE' if not exists $ENV{HTTPS_KEYSIZE};
40 local $ENV{'HTTPS'} = 'ON';
41 local $ENV{'HTTPS_KEYSIZE'} = 512;
42 is $cgi->https(), 'ON', 'scalar context to check SSL is on';
43 ok eq_set( [$cgi->https()], \@expect), 'list context returns https keys';