| 1 | package HTTP::Cookies; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use HTTP::Date qw(str2time parse_date time2str); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use HTTP::Headers::Util qw(_split_header_words join_header_words); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 6 | our $EPOCH_OFFSET; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 6 | our $VERSION = '6.11'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # Legacy: because "use "HTTP::Cookies" used be the ONLY way | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # to load the class HTTP::Cookies::Netscape. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 6 | require HTTP::Cookies::Netscape; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 6 | $EPOCH_OFFSET = 0; # difference from Unix epoch | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # A HTTP::Cookies object is a hash. The main attribute is the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # COOKIES 3 level hash: $self->{COOKIES}{$domain}{$path}{$key}. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | sub new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 33 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 33 | my $self = bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | COOKIES => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 33 | my %cnf = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 33 | for (keys %cnf) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 7 | $self->{lc($_)} = $cnf{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 33 | $self->load; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 33 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | sub add_cookie_header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 70 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_cookie_header: called CC=39 SCAR=38.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 70 | ▶ | my $request = shift || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || (return)
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 70 | my $url = $request->uri; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 70 | my $scheme = $url->scheme; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 70 | ▶ | unless ($scheme =~ /^https?\z/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 67 | my $domain = _host($request, $url); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 67 | ▶ | $domain = "$domain.local" unless $domain =~ /\./; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 67 | my $secure_request = ($scheme eq "https"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 67 | my $req_path = _url_path($url); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 67 | my $req_port = $url->port; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 67 | my $now = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 67 | ▶ | _normalize_path($req_path) if $req_path =~ /%/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 67 | my @cval; # cookie values for the "Cookie" header | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | my $set_ver; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 67 | my $netscape_only = 0; # An exact domain match applies to any cookie | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 67 | ▶ | while ($domain =~ /\./) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # Checking $domain for cookies" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 252 | my $cookies = $self->{COOKIES}{$domain}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 252 | ▶ | next unless $cookies; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 57 | ▶ | if ($self->{delayload} && defined($cookies->{'//+delayload'})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"delayload"} and defined $cookies->{"//+delayload"}
MC/DC0%0/2
$self->{"delayload"} and defined $cookies->{"//+delayload"}
$self->{"delayload"}
defined $cookies->{"//+delayload"}
Truth table33%1/3
A and B
A= $self->{"delayload"}B= defined $cookies->{"//+delayload"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | my $cookie_data = $cookies->{'//+delayload'}{'cookie'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | delete $self->{COOKIES}{$domain}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | $self->load_cookie($cookie_data->[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $cookies = $self->{COOKIES}{$domain}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | next unless $cookies; # should not really happen | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # Want to add cookies corresponding to the most specific paths | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # first (i.e. longest path first) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 57 | my $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 57 | for $path (sort {length($b) <=> length($a) } keys %$cookies) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 67 | ▶ | if (index($req_path, $path) != 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 7 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 60 | my($key,$array); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 60 | ▶ | while (($key,$array) = each %{$cookies->{$path}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 75 | my($version,$val,$port,$path_spec,$secure,$expires) = @$array; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 75 | ▶ | if ($secure && !$secure_request) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$secure and not $secure_request
MC/DC100%2/2
$secure and not $secure_request
$secure
not $secure_request
Truth table100%3/3
A and not(B)
A= $secureB= not $secure_request
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 74 | ▶ | if ($expires && $expires < $now) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$expires and $expires < $now
MC/DC0%0/2
$expires and $expires < $now
$expires
$expires < $now
Truth table66%2/3
A and B
A= $expiresB= $expires < $now
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 74 | ▶ | if ($port) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 7 | my $found; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 7 | ▶ | if ($port =~ s/^_//) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # The corresponding Set-Cookie attribute was empty | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 4 | ▶ | $found++ if $port eq $req_port; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 4 | $port = ""; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 3 | my $p; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 3 | for $p (split(/,/, $port)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 7 | ▶ | $found++, last if $p eq $req_port; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 7 | ▶ | unless ($found) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 74 | ▶ | if ($version > 0 && $netscape_only) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$version > 0 and $netscape_only
MC/DC0%0/2
$version > 0 and $netscape_only
$version > 0
$netscape_only
Truth table66%2/3
A and B
A= $version > 0B= $netscape_only
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # set version number of cookie header. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # XXX: What should it be if multiple matching | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # Set-Cookie headers have different versions themselves | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 74 | ▶ | if (!$set_ver++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 50 | ▶ | if ($version >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 18 | push(@cval, "\$Version=$version"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | elsif (!$self->{hide_cookie2}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 32 | $request->header(Cookie2 => '$Version="1"'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | # do we need to quote the value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 74 | ▶ | if ($val =~ /\W/ && $version) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$val =~ /\W/ and $version
MC/DC0%0/2
$val =~ /\W/ and $version
$val =~ /\W/
$version
Truth table66%2/3
A and B
A= $val =~ /\W/B= $version
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $val =~ s/([\\\"])/\\$1/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $val = qq("$val"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # and finally remember this cookie | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 74 | push(@cval, "$key=$val"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 74 | ▶ | if ($version >= 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 31 | ▶ | push(@cval, qq(\$Path="$path")) if $path_spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 31 | ▶ | push(@cval, qq(\$Domain="$domain")) if $domain =~ /^\./; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 31 | ▶ | if (defined $port) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 7 | my $p = '$Port'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 7 | ▶ | $p .= qq(="$port") if length $port; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 7 | push(@cval, $p); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } continue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # Try with a more general domain, alternately stripping | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # leading name components and leading dots. When this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # results in a domain with no leading dot, it is for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | # Netscape cookie compatibility only: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | # a.b.c.net Any cookie | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | # .b.c.net Any cookie | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | # b.c.net Netscape cookie only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # .c.net Any cookie | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 252 | ▶ | if ($domain =~ s/^\.+//) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 126 | $netscape_only = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 126 | $domain =~ s/[^.]*//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 126 | $netscape_only = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 67 | ▶ | if (@cval) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 50 | ▶ | if (my $old = $request->header("Cookie")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | unshift(@cval, $old); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 50 | $request->header(Cookie => join("; ", @cval)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 50 | ▶ | if (my $hash = $request->{_http_cookies}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 8 | %$hash = (map split(/=/, $_, 2), @cval); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 67 | $request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | sub get_cookies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 9 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_cookies: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 9 | my $url = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 9 | ▶ | $url = "https://$url" unless $url =~ m,^[a-zA-Z][a-zA-Z0-9.+\-]*:,; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 9 | require HTTP::Request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 9 | my $req = HTTP::Request->new(GET => $url); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 9 | my $cookies = $req->{_http_cookies} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 9 | $self->add_cookie_header($req); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 9 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 8 | ▶ | return map $cookies->{$_}, @_ if wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 7 | return $cookies->{$_[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 1 | return $cookies; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | sub extract_cookies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 70 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
extract_cookies: called CC=58 SCAR=40.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 70 | ▶ | my $response = shift || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift() || (return)
MC/DC0%0/1
shift() || (return)
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 70 | my @set = _split_header_words($response->_header("Set-Cookie2")); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 70 | my @ns_set = $response->_header("Set-Cookie"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 70 | ▶ | return $response unless @set || @ns_set; # quick exit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@set or @ns_set
MC/DC100%2/2
@set or @ns_set
@set
@ns_set
Truth table100%3/3
A or B
A= @setB= @ns_set
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 63 | my $request = $response->request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 63 | my $url = $request->uri; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 63 | my $req_host = _host($request, $url); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 63 | ▶ | $req_host = "$req_host.local" unless $req_host =~ /\./; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 63 | my $req_port = $url->port; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 63 | my $req_path = _url_path($url); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 63 | ▶ | _normalize_path($req_path) if $req_path =~ /%/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 63 | ▶ | if (@ns_set) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | # The old Netscape cookie format for Set-Cookie | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | # http://curl.haxx.se/rfc/cookie_spec.html | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # can for instance contain an unquoted "," in the expires | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # field, so we have to use this ad-hoc parser. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 33 | my $now = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # Build a hash of cookies that was present in Set-Cookie2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | # headers. We need to skip them if we also find them in a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # Set-Cookie header. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 33 | my %in_set2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 33 | for (@set) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 2 | $in_set2{$_->[0]}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 33 | my $set; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 33 | for $set (@ns_set) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 43 | $set =~ s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 43 | my @cur; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | my $param; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 43 | my $expires; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 43 | my $first_param = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 43 | for $param (@{_split_text($set)}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 108 | ▶ | next unless length($param); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 107 | my($k,$v) = split(/\s*=\s*/, $param, 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 107 | ▶ | if (defined $v) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 105 | $v =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | #print "$k => $v\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 2 | $k =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | #print "$k => undef"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 107 | ▶ | if (!$first_param && lc($k) eq "expires") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
not $first_param and lc $k eq "expires"
MC/DC100%2/2
not $first_param and lc $k eq "expires"
not $first_param
lc $k eq "expires"
Truth table100%3/3
not(A) and B
A= not $first_paramB= lc $k eq "expires"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 14 | my $etime = str2time($v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 14 | ▶ | if (defined $etime) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 12 | push(@cur, "Max-Age" => $etime - $now); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 12 | $expires++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | # parse_date can deal with years outside the range of time_t, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 2 | my($year, $mon, $day, $hour, $min, $sec, $tz) = parse_date($v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 2 | ▶ | if ($year) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 2 | my $thisyear = (gmtime)[5] + 1900; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 2 | ▶ | if ($year < $thisyear) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 2 | push(@cur, "Max-Age" => -1); # any negative value will do | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 2 | $expires++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | elsif ($year >= $thisyear + 10) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | # the date is at least 10 years into the future, just replace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | # it with something approximate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | push(@cur, "Max-Age" => 10 * 365 * 24 * 60 * 60); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | $expires++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | ▶ | elsif (!$first_param && lc($k) eq 'max-age') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
not $first_param and lc $k eq "max-age"
MC/DC100%2/2
not $first_param and lc $k eq "max-age"
not $first_param
lc $k eq "max-age"
Truth table100%3/3
not(A) and B
A= not $first_paramB= lc $k eq "max-age"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 1 | $expires++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | ▶ | elsif (!$first_param && lc($k) =~ /^(?:version|discard|ns-cookie)/) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
not $first_param and lc($k) =~ /^(?:version|discard|ns-cookie)/
MC/DC100%2/2
not $first_param and lc($k) =~ /^(?:version|discard|ns-cookie)/
not $first_param
lc($k) =~ /^(?:version|discard|ns-cookie)/
Truth table100%3/3
not(A) and B
A= not $first_paramB= lc($k) =~ /^(?:version|discard|ns-cookie)/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | # ignore | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 90 | push(@cur, $k => $v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 107 | $first_param = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 43 | ▶ | next unless @cur; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 42 | ▶ | next if $in_set2{$cur[0]}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | # push(@cur, "Port" => $req_port); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 41 | ▶ | push(@cur, "Discard" => undef) unless $expires; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 41 | push(@cur, "Version" => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 41 | push(@cur, "ns-cookie" => 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 41 | push(@set, \@cur); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | SET_COOKIE: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 63 | for my $set (@set) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 77 | ▶ | next unless @$set >= 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 77 | my $key = shift @$set; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 77 | my $val = shift @$set; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 77 | my %hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 77 | ▶ | while (@$set) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 236 | my $k = shift @$set; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 236 | my $v = shift @$set; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 236 | my $lc = lc($k); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | # don't loose case distinction for unknown fields | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 236 | ▶ | $k = $lc if $lc =~ /^(?:discard|domain|max-age| | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | path|port|secure|version)$/x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 236 | ▶ | if ($k eq "discard" || $k eq "secure") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$k eq "discard" or $k eq "secure"
MC/DC100%2/2
$k eq "discard" or $k eq "secure"
$k eq "discard"
$k eq "secure"
Truth table100%3/3
A or B
A= $k eq "discard"B= $k eq "secure"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 33 | ▶ | $v = 1 unless defined $v; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 236 | ▶ | next if exists $hash{$k}; # only first value is significant | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 236 | $hash{$k} = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 77 | my %orig_hash = %hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 77 | my $version = delete $hash{version}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 77 | ▶ | $version = 1 unless defined($version); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 77 | my $discard = delete $hash{discard}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 77 | my $secure = delete $hash{secure}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 77 | my $maxage = delete $hash{'max-age'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 77 | my $ns_cookie = delete $hash{'ns-cookie'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # Check domain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 77 | my $domain = delete $hash{domain}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 77 | ▶ | $domain = lc($domain) if defined $domain; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 77 | ▶ | if (defined($domain) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $domain and $domain ne $req_host and $domain ne ".$req_host"
defined $domain and $domain ne $req_host
MC/DC100%3/3
defined $domain and $domain ne $req_host and $domain ne ".$req_host"
defined $domain
$domain ne $req_host
$domain ne ".$req_host"
Truth table100%4/4
A and B and C
A= defined $domainB= $domain ne $req_hostC= $domain ne ".$req_host"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | && $domain ne $req_host && $domain ne ".$req_host") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 17 | ▶ | if ($domain !~ /\./ && $domain ne "local") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $domain =~ /\./ and $domain ne "local"
MC/DC0%0/2
not $domain =~ /\./ and $domain ne "local"
not $domain =~ /\./
$domain ne "local"
Truth table33%1/3
not(A) and B
A= not $domain =~ /\./B= $domain ne "local"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | next SET_COOKIE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 17 | ▶ | $domain = ".$domain" unless $domain =~ /^\./; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 17 | ▶ | if ($domain =~ /\.\d+$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 1 | next SET_COOKIE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 16 | my $len = length($domain); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 16 | ▶ | unless (substr($req_host, -$len) eq $domain) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | next SET_COOKIE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 16 | my $hostpre = substr($req_host, 0, length($req_host) - $len); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 16 | ▶ | if ($hostpre =~ /\./ && !$ns_cookie) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$hostpre =~ /\./ and not $ns_cookie
MC/DC100%2/2
$hostpre =~ /\./ and not $ns_cookie
$hostpre =~ /\./
not $ns_cookie
Truth table100%3/3
A and not(B)
A= $hostpre =~ /\./B= not $ns_cookie
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 2 | next SET_COOKIE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 60 | $domain = $req_host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 74 | my $path = delete $hash{path}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 74 | my $path_spec; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 74 | ▶ | if (defined $path && $path ne '') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $path and $path ne ""
MC/DC100%2/2
defined $path and $path ne ""
defined $path
$path ne ""
Truth table100%3/3
A and B
A= defined $pathB= $path ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 49 | $path_spec++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 49 | ▶ | _normalize_path($path) if $path =~ /%/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 49 | ▶ | if (!$ns_cookie && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $ns_cookie and substr($req_path, 0, length $path) ne $path
MC/DC100%2/2
not $ns_cookie and substr($req_path, 0, length $path) ne $path
not $ns_cookie
substr($req_path, 0, length $path) ne $path
Truth table100%3/3
not(A) and B
A= not $ns_cookieB= substr($req_path, 0, length $path) ne $path
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | substr($req_path, 0, length($path)) ne $path) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 4 | next SET_COOKIE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 25 | $path = $req_path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 25 | $path =~ s,/[^/]*$,,; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 25 | ▶ | $path = "/" unless length($path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 70 | my $port; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 70 | ▶ | if (exists $hash{port}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 5 | $port = delete $hash{port}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 5 | ▶ | if (defined $port) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 3 | $port =~ s/\s+//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 3 | my $found; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 3 | for my $p (split(/,/, $port)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 7 | ▶ | unless ($p =~ /^\d+$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | next SET_COOKIE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 7 | ▶ | $found++ if $p eq $req_port; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 3 | ▶ | unless ($found) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 1 | next SET_COOKIE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 2 | $port = "_$req_port"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 69 | ▶ | $self->set_cookie($version,$key,$val,$path,$domain,$port,$path_spec,$secure,$maxage,$discard, \%hash) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | if $self->set_cookie_ok(\%orig_hash); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 63 | $response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | sub set_cookie_ok | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 69 | ▶ | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_cookie_ok: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | sub set_cookie | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 78 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_cookie: called CC=13 SCAR=26.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 78 | my($version, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | $key, $val, $path, $domain, $port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | $path_spec, $secure, $maxage, $discard, $rest) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | # path and key can not be empty (key can't start with '$') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 78 | ▶ | return $self if !defined($path) || $path !~ m,^/, || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
not defined $path && $path =~ m[^/] && defined $key or $key =~ /^\$/
defined $path && $path =~ m[^/] && defined $key
defined $path and $path =~ m[^/]
MC/DC0%0/4
not defined $path && $path =~ m[^/] && defined $key or $key =~ /^\$/
defined $path
$path =~ m[^/]
defined $key
$key =~ /^\$/
Truth table20%1/5
not(A and B && C) or D
A= defined $pathB= $path =~ m[^/]C= defined $keyD= $key =~ /^\$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | !defined($key) || $key =~ m,^\$,; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | # ensure legal port | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 78 | ▶ | if (defined $port) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 4 | ▶ | return $self unless $port =~ /^_?\d+(?:,\d+)*$/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 78 | my $expires; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 78 | ▶ | if (defined $maxage) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 27 | ▶ | if ($maxage <= 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 8 | delete $self->{COOKIES}{$domain}{$path}{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 8 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 19 | $expires = time() + $maxage; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 70 | ▶ | $version = 0 unless defined $version; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 70 | my @array = ($version, $val,$port, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | $path_spec, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | $secure, $expires, $discard); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 70 | ▶ | push(@array, {%$rest}) if defined($rest) && %$rest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $rest and %$rest
MC/DC100%2/2
defined $rest and %$rest
defined $rest
%$rest
Truth table100%3/3
A and B
A= defined $restB= %$rest
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | # trim off undefined values at end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 70 | ▶ | pop(@array) while !defined $array[-1]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 70 | $self->{COOKIES}{$domain}{$path}{$key} = \@array; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 70 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | sub save | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
save: called CC=6 SCAR=18.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | my %args = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | file => $self->{'file'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 2 | ▶ | ignore_discard => $self->{'ignore_discard'}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | @_ == 1 ? ( file => $_[0] ) : @_ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 2 | ▶ | Carp::croak('Unexpected argument to save method') if keys %args > 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 2 | ▶ | my $file = $args{'file'} || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{'file'} || (return)
MC/DC0%0/1
$args{'file'} || (return)
$args{'file'}
Truth table50%1/2
A
A= $args{'file'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 2 | ▶ | open(my $fh, '>', $file) or die "Can't open $file: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 2 | print {$fh} "#LWP-Cookies-1.0\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 2 | print {$fh} $self->as_string(!$args{'ignore_discard'}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 2 | ▶ | close $fh or die "Can't close $file: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | sub load | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 30 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load: called CC=10 SCAR=23.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 30 | ▶ | my $file = shift || $self->{'file'} || return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
shift() || $self->{'file'} || (return)
shift() or $self->{"file"}
MC/DC50%1/2
shift() || $self->{'file'} || (return)
shift()
$self->{"file"}
Truth table66%2/3
A or B
A= shift()B= $self->{"file"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 2 | local $/ = "\n"; # make sure we got standard record separator | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 2 | ▶ | open(my $fh, '<', $file) or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | # check that we have the proper header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 2 | my $magic = <$fh>; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 2 | chomp $magic; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 2 | ▶ | unless ($magic =~ /^#LWP-Cookies-\d+\.\d+/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | warn "$file does not seem to contain cookies"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | # go through the file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 2 | ▶ | while (my $line = <$fh>) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 7 | chomp $line; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 7 | ▶ | next unless $line =~ s/^Set-Cookie3:\s*//; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 7 | my $cookie; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 7 | for $cookie (_split_header_words($line)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 7 | my($key,$val) = splice(@$cookie, 0, 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 7 | my %hash; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 7 | ▶ | while (@$cookie) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 29 | my $k = shift @$cookie; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 29 | my $v = shift @$cookie; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 29 | $hash{$k} = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 7 | my $version = delete $hash{version}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 7 | my $path = delete $hash{path}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 7 | my $domain = delete $hash{domain}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 7 | my $port = delete $hash{port}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 7 | my $expires = str2time(delete $hash{expires}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 7 | my $path_spec = exists $hash{path_spec}; delete $hash{path_spec}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 7 | my $secure = exists $hash{secure}; delete $hash{secure}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 7 | my $discard = exists $hash{discard}; delete $hash{discard}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 7 | my @array = ($version, $val, $port, $path_spec, $secure, $expires, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | $discard); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 7 | ▶ | push(@array, \%hash) if %hash; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 7 | $self->{COOKIES}{$domain}{$path}{$key} = \@array; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | sub revert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
revert: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | $self->clear->load; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | sub clear | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear: called CC=5 SCAR=26.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 5 | ▶ | if (@_ == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 5 | $self->{COOKIES} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | elsif (@_ == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | delete $self->{COOKIES}{$_[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | elsif (@_ == 2) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | delete $self->{COOKIES}{$_[0]}{$_[1]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | elsif (@_ == 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | delete $self->{COOKIES}{$_[0]}{$_[1]}{$_[2]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | Carp::carp('Usage: $c->clear([domain [,path [,key]]])'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 5 | $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | sub clear_temporary_cookies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 2 | ▶ | my($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_temporary_cookies: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | $self->scan(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 6 | ▶ | if($_[9] or # "Discard" flag set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
Branch: 1 branch
Condition66%2/3
$_[9] or not $_[8]
MC/DC50%1/2
$_[9] or not $_[8]
$_[9]
not $_[8]
Truth table66%2/3
A or not(B)
A= $_[9]B= not $_[8]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | not $_[8]) { # No expire field? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 3 | $_[8] = -1; # Set the expire/max_age field | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 3 | $self->set_cookie(@_); # Clear the cookie | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 2 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | sub DESTROY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 29 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 29 | local($., $@, $!, $^E, $?); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 29 | ▶ | $self->save if $self->{'autosave'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | sub scan | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 60 | ▶ | my($self, $cb) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scan: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 60 | my($domain,$path,$key); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 60 | for $domain (sort keys %{$self->{COOKIES}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 90 | for $path (sort keys %{$self->{COOKIES}{$domain}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 110 | for $key (sort keys %{$self->{COOKIES}{$domain}{$path}}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | my($version,$val,$port,$path_spec, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | $secure,$expires,$discard,$rest) = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 134 | @{$self->{COOKIES}{$domain}{$path}{$key}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 134 | ▶ | $rest = {} unless defined($rest); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 134 | &$cb($version,$key,$val,$path,$domain,$port, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | $path_spec,$secure,$expires,$discard,$rest); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | sub as_string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 23 | ▶ | my($self, $skip_discard) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 23 | my @res; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | $self->scan(sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 49 | ▶ | my($version,$key,$val,$path,$domain,$port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=9 SCAR=22.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | $path_spec,$secure,$expires,$discard,$rest) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 49 | ▶ | return if $discard && $skip_discard; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$discard and $skip_discard
MC/DC0%0/2
$discard and $skip_discard
$discard
$skip_discard
Truth table66%2/3
A and B
A= $discardB= $skip_discard
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 49 | my @h = ($key, $val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 49 | push(@h, "path", $path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 49 | push(@h, "domain" => $domain); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 49 | ▶ | push(@h, "port" => $port) if defined $port; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 49 | ▶ | push(@h, "path_spec" => undef) if $path_spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 49 | ▶ | push(@h, "secure" => undef) if $secure; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 49 | ▶ | push(@h, "expires" => HTTP::Date::time2isoz($expires)) if $expires; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 49 | ▶ | push(@h, "discard" => undef) if $discard; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 49 | my $k; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 49 | for $k (sort keys %$rest) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 3 | push(@h, $k, $rest->{$k}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 49 | push(@h, "version" => $version); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 49 | push(@res, "Set-Cookie3: " . join_header_words(\@h)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 23 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 23 | join("\n", @res, ""); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | sub _host | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 130 | ▶ | my($request, $url) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_host: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 130 | ▶ | if (my $h = $request->header("Host")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 32 | $h =~ s/:\d+$//; # might have a port as well | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 32 | return lc($h); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 98 | return lc($url->host); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | sub _url_path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 130 | ▶ | my $url = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_url_path: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 130 | my $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 130 | ▶ | if($url->can('epath')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | $path = $url->epath; # URI::URL method | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 130 | $path = $url->path; # URI::_generic method | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 130 | ▶ | $path = "/" unless length $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 130 | $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | sub _normalize_path # so that plain string compare can be used | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 6 | ▶ | my $x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_normalize_path: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 6 | $_[0] =~ s/%([0-9a-fA-F][0-9a-fA-F])/ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 35 | $x = uc($1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 35 | ▶ | $x eq "2F" || $x eq "25" ? "%$x" : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$x eq "2F" or $x eq 25
MC/DC100%2/2
$x eq "2F" or $x eq 25
$x eq "2F"
$x eq 25
Truth table100%3/3
A or B
A= $x eq "2F"B= $x eq 25
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | pack("C", hex($x)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | /eg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 6 | $_[0] =~ s/([\0-\x20\x7f-\xff])/sprintf("%%%02X",ord($1))/eg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | # deals with splitting values by ; and the fact that they could | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | # be in quotes which can also have escaping. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | sub _split_text { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 45 | ▶ | my $val = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_split_text: called CC=10 SCAR=23.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 45 | my @vals = grep { $_ ne q{} } split(/([;\\"])/, $val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 45 | my @chunks; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | # divide it up into chunks to be processed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 45 | my $in_string = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 45 | my @current_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 45 | ▶ | for(my $i = 0; $i < @vals; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 206 | my $chunk = $vals[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 206 | ▶ | if($in_string) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 18 | ▶ | if($chunk eq q{\\}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | # don't care about next char probably. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | # having said that, probably need to be appending to the chunks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | # just dropping this. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 2 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 2 | ▶ | if($i < @vals) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 2 | push @current_string, $vals[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | } elsif($chunk eq q{"}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 4 | $in_string = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 12 | push @current_string, $chunk; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 188 | ▶ | if($chunk eq q{"}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 4 | $in_string = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | elsif($chunk eq q{;}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 72 | push @chunks, join(q{}, @current_string); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 72 | @current_string = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 112 | push @current_string, $chunk; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 45 | ▶ | push @chunks, join(q{}, @current_string) if @current_string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 45 | s/^\s+// for @chunks; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 45 | return \@chunks; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 6 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | HTTP::Cookies - HTTP cookie jars | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | version 6.11 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | use HTTP::Cookies; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | $cookie_jar = HTTP::Cookies->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | file => "$ENV{'HOME'}/lwp_cookies.dat", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | autosave => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | use LWP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | my $browser = LWP::UserAgent->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | $browser->cookie_jar($cookie_jar); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | Or for an empty and temporary cookie jar: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | use LWP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | my $browser = LWP::UserAgent->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | $browser->cookie_jar( {} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | This class is for objects that represent a "cookie jar" -- that is, a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | database of all the HTTP cookies that a given LWP::UserAgent object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | knows about. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | Cookies are a general mechanism which server side connections can use | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | to both store and retrieve information on the client side of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | connection. For more information about cookies refer to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | L<Cookie Spec|http://curl.haxx.se/rfc/cookie_spec.html> and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | L<Cookie Central|http://www.cookiecentral.com>. This module also implements the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | new style cookies described in L<RFC 2965|https://tools.ietf.org/html/rfc2965>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | The two variants of cookies are supposed to be able to coexist happily. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | Instances of the class I<HTTP::Cookies> are able to store a collection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | of Set-Cookie2: and Set-Cookie: headers and are able to use this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | information to initialize Cookie-headers in I<HTTP::Request> objects. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | The state of a I<HTTP::Cookies> object can be saved in and restored from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | files. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | =head1 LIMITATIONS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | This module does not support L<< Public Suffix|https://publicsuffix.org/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | >> encouraged by a more recent standard, L<< RFC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 6265|https://tools.ietf.org/html/rfc6265 >>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | This module's shortcomings mean that a malicious Web site can set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | cookies to track your user agent across all sites under a top level | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | domain. See F<< t/publicsuffix.t >> in this module's distribution for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | L<< HTTP::CookieJar::LWP >> supports Public Suffix, but only provides a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | limited subset of this module's functionality and L<< does not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | support|HTTP::CookieJar/LIMITATIONS-AND-CAVEATS >> standards older than | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | I<RFC 6265>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | The following methods are provided: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | =item $cookie_jar = HTTP::Cookies->new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | The constructor takes hash style parameters. The following | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | parameters are recognized: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | file: name of the file to restore cookies from and save cookies to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | autosave: save during destruction (bool) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | ignore_discard: save even cookies that are requested to be discarded (bool) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | hide_cookie2: do not add Cookie2 header to requests | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | Future parameters might include (not yet implemented): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | max_cookies 300 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | max_cookies_per_domain 20 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | max_cookie_size 4096 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | no_cookies list of domain names that we never return cookies to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | =item $cookie_jar->get_cookies( $url_or_domain ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | =item $cookie_jar->get_cookies( $url_or_domain, $cookie_key,... ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | Returns a hash of the cookies that applies to the given URL. If a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | domainname is given as argument, then a prefix of "https://" is assumed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | If one or more $cookie_key parameters are provided return the given values, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | or C<undef> if the cookie isn't available. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | =item $cookie_jar->add_cookie_header( $request ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | The add_cookie_header() method will set the appropriate Cookie:-header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | for the I<HTTP::Request> object given as argument. The $request must | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | have a valid url attribute before this method is called. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | =item $cookie_jar->extract_cookies( $response ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | The extract_cookies() method will look for Set-Cookie: and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | Set-Cookie2: headers in the I<HTTP::Response> object passed as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | argument. Any of these headers that are found are used to update | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | the state of the $cookie_jar. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | =item $cookie_jar->set_cookie( $version, $key, $val, $path, $domain, $port, $path_spec, $secure, $maxage, $discard, \%rest ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | The set_cookie() method updates the state of the $cookie_jar. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | $key, $val, $domain, $port and $path arguments are strings. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | $path_spec, $secure, $discard arguments are boolean values. The $maxage | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | value is a number indicating number of seconds that this cookie will | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | live. A value of $maxage <= 0 will delete this cookie. The $version argument | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | sets the version of the cookie; the default value is 0 ( original Netscape | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | spec ). Setting $version to another value indicates the RFC to which the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | cookie conforms (e.g. version 1 for RFC 2109). %rest defines various other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | attributes like "Comment" and "CommentURL". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | =item $cookie_jar->save | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | =item $cookie_jar->save( $file ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | =item $cookie_jar->save( file => $file, ignore_discard => $ignore_discard ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | This method saves the state of the $cookie_jar to a file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | The state can then be restored later using the load() method. If a | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | filename is not specified we will use the name specified during | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | construction. If the $ignore_discard value is true (or not specified, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | but attribute I<ignore_discard> was set at cookie jar construction), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | then we will even save cookies that are marked to be discarded. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | The default is to save a sequence of "Set-Cookie3" lines. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | "Set-Cookie3" is a proprietary LWP format, not known to be compatible | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | with any browser. The I<HTTP::Cookies::Netscape> sub-class can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | be used to save in a format compatible with Netscape. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | =item $cookie_jar->load | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | =item $cookie_jar->load( $file ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | This method reads the cookies from the file and adds them to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | $cookie_jar. The file must be in the format written by the save() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | method. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | =item $cookie_jar->revert | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | This method empties the $cookie_jar and re-loads the $cookie_jar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | from the last save file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | =item $cookie_jar->clear | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | =item $cookie_jar->clear( $domain ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | =item $cookie_jar->clear( $domain, $path ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | =item $cookie_jar->clear( $domain, $path, $key ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | Invoking this method without arguments will empty the whole | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | $cookie_jar. If given a single argument only cookies belonging to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | that domain will be removed. If given two arguments, cookies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | belonging to the specified path within that domain are removed. If | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | given three arguments, then the cookie with the specified key, path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | and domain is removed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | =item $cookie_jar->clear_temporary_cookies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | Discard all temporary cookies. Scans for all cookies in the jar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | with either no expire field or a true C<discard> flag. To be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | called when the user agent shuts down according to RFC 2965. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | =item $cookie_jar->scan( \&callback ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | The argument is a subroutine that will be invoked for each cookie | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | stored in the $cookie_jar. The subroutine will be invoked with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | the following arguments: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 1 key | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 2 val | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 3 path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 4 domain | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 5 port | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 6 path_spec | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 7 secure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 8 expires | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 9 discard | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 10 hash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | =item $cookie_jar->as_string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | =item $cookie_jar->as_string( $skip_discardables ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | The as_string() method will return the state of the $cookie_jar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | represented as a sequence of "Set-Cookie3" header lines separated by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | "\n". If $skip_discardables is TRUE, it will not return lines for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | cookies with the I<Discard> attribute. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | L<HTTP::Cookies::Netscape>, L<HTTP::Cookies::Microsoft> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | Gisle Aas <gisle@activestate.com> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | This software is copyright (c) 2002 by Gisle Aas. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||