1use strict; 2use warnings FATAL => 'all'; 3 4use Apache::Test; 5 6use Apache::TestUtil; 7use Apache::TestRequest qw(GET_BODY GET_HEAD); 8 9plan tests => 6, need_lwp; 10 11require HTTP::Cookies; 12 13my $location = "/apreq_cookie_test"; 14 15{ 16 my $test = 'netscape'; 17 my $key = 'apache'; 18 my $value = 'ok'; 19 my $cookie = qq{$key=$value}; 20 ok t_cmp(GET_BODY("$location?test=$test&key=$key", Cookie => $cookie), 21 $value, 22 $test); 23} 24{ 25 my $test = 'rfc'; 26 my $key = 'apache'; 27 my $value = 'ok'; 28 my $cookie = qq{\$Version="1"; $key="$value"; \$Path="$location"}; 29 ok t_cmp(GET_BODY("$location?test=$test&key=$key", Cookie => $cookie), 30 qq{"$value"}, 31 $test); 32} 33{ 34 my $test = 'encoded value with space'; 35 my $key = 'apache'; 36 my $value = 'okie dokie'; 37 my $cookie = "$key=" . join '', 38 map {/ / ? '+' : sprintf '%%%.2X', ord} split //, $value; 39 ok t_cmp(GET_BODY("$location?test=$test&key=$key", Cookie => $cookie), 40 $value, 41 $test); 42} 43{ 44 my $test = 'bake'; 45 my $key = 'apache'; 46 my $value = 'ok'; 47 my $cookie = "$key=$value"; 48 my ($header) = GET_HEAD("$location?test=$test&key=$key", 49 Cookie => $cookie) =~ /^#Set-Cookie:\s+(.+)/m; 50 ok t_cmp($header, $cookie, $test); 51} 52{ 53 my $test = 'bake2'; 54 my $key = 'apache'; 55 my $value = 'ok'; 56 my $cookie = qq{\$Version="1"; $key="$value"; \$Path="$location"}; 57 my ($header) = GET_HEAD("$location?test=$test&key=$key", 58 Cookie => $cookie) =~ /^#Set-Cookie2:\s+(.+)/m; 59 ok t_cmp($header, qq{$key="$value"; Version=1; path="$location"}, $test); 60} 61{ 62 my $test = 'httponly'; 63 my $key = 'apache'; 64 my $value = 'ok'; 65 my $cookie = "$key=$value; HttpOnly"; 66 my ($header) = GET_HEAD("$location?test=$test&key=$key", 67 Cookie => $cookie) =~ /^#Set-Cookie:\s+(.+)/m; 68 ok t_cmp($header, $cookie, $test); 69} 70