| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTTP::Session::State::Cookie; |
|
2
|
4
|
|
|
4
|
|
3006
|
use strict; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
135
|
|
|
3
|
4
|
|
|
4
|
|
2607
|
use HTTP::Session::State::Base; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
25
|
|
|
4
|
4
|
|
|
4
|
|
609
|
use Carp (); |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
69
|
|
|
5
|
4
|
|
|
4
|
|
21
|
use Scalar::Util (); |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
2896
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $COOKIE_CLASS = 'CGI::Cookie'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw/name path domain expires secure/); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
{ |
|
12
|
|
|
|
|
|
|
my $required = 0; |
|
13
|
|
|
|
|
|
|
sub _cookie_class { |
|
14
|
29
|
|
|
29
|
|
36
|
my $class = shift; |
|
15
|
29
|
100
|
|
|
|
63
|
unless ($required) { |
|
16
|
4
|
|
|
|
|
24
|
(my $klass = $COOKIE_CLASS) =~ s!::!/!g; |
|
17
|
4
|
|
|
|
|
8
|
$klass .= ".pm"; |
|
18
|
4
|
|
|
|
|
3978
|
require $klass; |
|
19
|
4
|
|
|
|
|
14084
|
$required++; |
|
20
|
|
|
|
|
|
|
} |
|
21
|
29
|
|
|
|
|
166
|
return $COOKIE_CLASS |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub new { |
|
26
|
20
|
|
|
20
|
1
|
395
|
my $class = shift; |
|
27
|
20
|
50
|
|
|
|
85
|
my %args = ref($_[0]) ? %{$_[0]} : @_; |
|
|
0
|
|
|
|
|
0
|
|
|
28
|
|
|
|
|
|
|
# set default values |
|
29
|
20
|
|
100
|
|
|
98
|
$args{name} ||= 'http_session_sid'; |
|
30
|
20
|
|
100
|
|
|
91
|
$args{path} ||= '/'; |
|
31
|
20
|
|
|
|
|
296
|
bless {%args}, $class; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub get_session_id { |
|
35
|
20
|
|
|
20
|
1
|
205
|
my ($self, $req) = @_; |
|
36
|
|
|
|
|
|
|
|
|
37
|
20
|
|
66
|
|
|
168
|
my $cookie_header = $ENV{HTTP_COOKIE} || (Scalar::Util::blessed($req) ? $req->header('Cookie') : $req->{HTTP_COOKIE}); |
|
38
|
20
|
100
|
|
|
|
2981
|
return unless $cookie_header; |
|
39
|
|
|
|
|
|
|
|
|
40
|
18
|
|
|
|
|
48
|
my %jar = _cookie_class()->parse($cookie_header); |
|
41
|
18
|
|
|
|
|
4666
|
my $cookie = $jar{$self->name}; |
|
42
|
18
|
100
|
|
|
|
162
|
return $cookie ? $cookie->value : undef; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub response_filter { |
|
46
|
11
|
|
|
11
|
1
|
105
|
my ($self, $session_id, $res) = @_; |
|
47
|
11
|
100
|
|
|
|
385
|
Carp::croak "missing session_id" unless $session_id; |
|
48
|
|
|
|
|
|
|
|
|
49
|
9
|
|
|
|
|
34
|
$self->header_filter($session_id, $res); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub header_filter { |
|
53
|
11
|
|
|
11
|
1
|
33
|
my ($self, $session_id, $res) = @_; |
|
54
|
11
|
50
|
|
|
|
30
|
Carp::croak "missing session_id" unless $session_id; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $cookie = _cookie_class()->new( |
|
57
|
|
|
|
|
|
|
sub { |
|
58
|
11
|
|
|
11
|
|
43
|
my %options = ( |
|
59
|
|
|
|
|
|
|
-name => $self->name, |
|
60
|
|
|
|
|
|
|
-value => $session_id, |
|
61
|
|
|
|
|
|
|
-path => $self->path, |
|
62
|
|
|
|
|
|
|
); |
|
63
|
11
|
100
|
|
|
|
126
|
$options{'-domain'} = $self->domain if $self->domain; |
|
64
|
11
|
100
|
|
|
|
97
|
$options{'-expires'} = $self->expires if $self->expires; |
|
65
|
11
|
100
|
|
|
|
89
|
$options{'-secure'} = $self->secure if $self->secure; |
|
66
|
11
|
|
|
|
|
153
|
%options; |
|
67
|
11
|
|
|
|
|
24
|
}->() |
|
68
|
|
|
|
|
|
|
); |
|
69
|
11
|
100
|
|
|
|
1629
|
if (Scalar::Util::blessed($res)) { |
|
70
|
10
|
|
|
|
|
31
|
$res->header( 'Set-Cookie' => $cookie->as_string ); |
|
71
|
10
|
|
|
|
|
1243
|
$res; |
|
72
|
|
|
|
|
|
|
} else { |
|
73
|
1
|
|
|
|
|
2
|
push @{$res->[1]}, 'Set-Cookie' => $cookie->as_string; |
|
|
1
|
|
|
|
|
6
|
|
|
74
|
1
|
|
|
|
|
68
|
$res; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
|
79
|
|
|
|
|
|
|
__END__ |