Commit | Line | Data |
---|---|---|
deafae52 SH |
1 | #!./perl -w |
2 | ||
3 | # Fixes RT 12909 | |
4 | ||
5 | use lib qw(t/lib); | |
6 | ||
7 | use Test::More tests => 7; | |
8 | use CGI; | |
9 | ||
5b898c55 FC |
10 | %ENV=(); |
11 | ||
deafae52 SH |
12 | my $cgi = CGI->new(); |
13 | ||
14 | { | |
15 | # http() without arguments should not cause warnings | |
16 | local $SIG{__WARN__} = sub { die @_ }; | |
17 | ok eval { $cgi->http(); 1 }, "http() without arguments doesn't warn"; | |
18 | ok eval { $cgi->https(); 1 }, "https() without arguments doesn't warn"; | |
19 | } | |
20 | ||
21 | { | |
22 | # Capitalization and the use of hyphens versus underscores are not significant. | |
23 | local $ENV{'HTTP_HOST'} = 'foo'; | |
24 | is $cgi->http('Host'), 'foo', 'http("Host") returns $ENV{HTTP_HOST}'; | |
25 | is $cgi->http('http-host'), 'foo', 'http("http-host") returns $ENV{HTTP_HOST}'; | |
26 | } | |
27 | ||
28 | { | |
29 | # Called with no arguments returns the list of HTTP environment variables | |
30 | local $ENV{'HTTPS_FOO'} = 'bar'; | |
31 | my @http = $cgi->http(); | |
32 | is scalar( grep /^HTTPS/, @http), 0, "http() doesn't return HTTPS variables"; | |
33 | } | |
34 | ||
35 | { | |
36 | # https() | |
37 | # The same as http(), but operates on the HTTPS environment variables present when the SSL protocol is in | |
38 | # effect. Can be used to determine whether SSL is turned on. | |
39 | local $ENV{'HTTPS'} = 'ON'; | |
40 | local $ENV{'HTTPS_KEYSIZE'} = 512; | |
41 | is $cgi->https(), 'ON', 'scalar context to check SSL is on'; | |
42 | ok eq_set( [$cgi->https()], [qw(HTTPS HTTPS_KEYSIZE)]), 'list context returns https keys'; | |
43 | } |