line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- Mode: Perl; indent-tabs-mode: nil; -*- |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Servlet::Http::Cookie; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
31730
|
use fields qw(name value comment domain maxage path secure version); |
|
1
|
|
|
|
|
3097
|
|
|
1
|
|
|
|
|
11
|
|
6
|
1
|
|
|
1
|
|
213
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
986
|
use Servlet::Util::Exception (); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $Fieldpat = '(comment|discard|domain|expires|max\-age|path|secure|version)'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
|
|
|
|
|
|
my $self = shift; |
15
|
|
|
|
|
|
|
my $name = shift; |
16
|
|
|
|
|
|
|
my $value = shift; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
unless ($name) { |
19
|
|
|
|
|
|
|
my $msg = 'cookie name needed'; |
20
|
|
|
|
|
|
|
Servlet::Util::IllegalArgumentException->throw($msg); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
if ($name !~ /^[[:alpha:]]+$/ || |
24
|
|
|
|
|
|
|
$name =~ /,;\s/ || |
25
|
|
|
|
|
|
|
$name =~ /^\$/ || |
26
|
|
|
|
|
|
|
$name =~ /$Fieldpat/i) { |
27
|
|
|
|
|
|
|
my $msg = "invalid cookie name [$name]"; |
28
|
|
|
|
|
|
|
Servlet::Util::IllegalArgumentException->throw($msg); |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$self = fields::new($self) unless ref $self; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$self->{name} = $name; |
34
|
|
|
|
|
|
|
$self->{value} = $value; |
35
|
|
|
|
|
|
|
$self->{comment} = undef; |
36
|
|
|
|
|
|
|
$self->{domain} = undef; |
37
|
|
|
|
|
|
|
$self->{maxage} = -1; |
38
|
|
|
|
|
|
|
$self->{path} = undef; |
39
|
|
|
|
|
|
|
$self->{secure} = undef; |
40
|
|
|
|
|
|
|
$self->{version} = 0; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
return $self; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub getComment { |
46
|
|
|
|
|
|
|
my $self = shift; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
return $self->{comment}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub getDomain { |
52
|
|
|
|
|
|
|
my $self = shift; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
return $self->{domain}; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub getMaxAge { |
58
|
|
|
|
|
|
|
my $self = shift; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
return $self->{maxage}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub getName { |
64
|
|
|
|
|
|
|
my $self = shift; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
return $self->{name}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub getPath { |
70
|
|
|
|
|
|
|
my $self = shift; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
return $self->{path}; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub getSecure { |
76
|
|
|
|
|
|
|
my $self = shift; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
return $self->{secure}; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub getValue { |
82
|
|
|
|
|
|
|
my $self = shift; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
return $self->{value}; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub getVersion { |
88
|
|
|
|
|
|
|
my $self = shift; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
return $self->{version}; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub setComment { |
94
|
|
|
|
|
|
|
my $self = shift; |
95
|
|
|
|
|
|
|
my $purpose = shift; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
$self->{comment} = $purpose; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
return 1; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub setDomain { |
103
|
|
|
|
|
|
|
my $self = shift; |
104
|
|
|
|
|
|
|
my $pattern = shift; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
$self->{domain} = lc($pattern); # IE allegedly needs this |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
return 1; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub setMaxAge { |
112
|
|
|
|
|
|
|
my $self = shift; |
113
|
|
|
|
|
|
|
my $expiry = shift; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
$self->{maxage} = $expiry; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
return 1; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub setPath { |
121
|
|
|
|
|
|
|
my $self = shift; |
122
|
|
|
|
|
|
|
my $uri = shift; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
$self->{path} = $uri; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
return 1; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub setSecure { |
130
|
|
|
|
|
|
|
my $self = shift; |
131
|
|
|
|
|
|
|
my $flag = shift; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
$self->{secure} = $flag; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
return 1; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub setValue { |
139
|
|
|
|
|
|
|
my $self = shift; |
140
|
|
|
|
|
|
|
my $newvalue = shift; |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
$self->{value} = $newvalue; |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
return 1; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub setVersion { |
148
|
|
|
|
|
|
|
my $self = shift; |
149
|
|
|
|
|
|
|
my $v = shift; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
$self->{version} = $v; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
return 1; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
1; |
157
|
|
|
|
|
|
|
__END__ |