| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package PAGI::Middleware::Session::State; |
|
2
|
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
174357
|
use strict; |
|
|
5
|
|
|
|
|
8
|
|
|
|
5
|
|
|
|
|
138
|
|
|
4
|
5
|
|
|
5
|
|
16
|
use warnings; |
|
|
5
|
|
|
|
|
6
|
|
|
|
5
|
|
|
|
|
955
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
PAGI::Middleware::Session::State - Base class for session state extraction |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package My::State; |
|
13
|
|
|
|
|
|
|
use parent 'PAGI::Middleware::Session::State'; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub extract { |
|
16
|
|
|
|
|
|
|
my ($self, $scope) = @_; |
|
17
|
|
|
|
|
|
|
# Return session ID or undef |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub inject { |
|
21
|
|
|
|
|
|
|
my ($self, $headers, $id, $options) = @_; |
|
22
|
|
|
|
|
|
|
# Push response header onto @$headers |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
PAGI::Middleware::Session::State defines the interface for session ID |
|
28
|
|
|
|
|
|
|
transport. Subclasses determine how the session ID is extracted from |
|
29
|
|
|
|
|
|
|
incoming requests and injected into outgoing responses. |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 METHODS |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head2 new |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $state = PAGI::Middleware::Session::State->new(%options); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Create a new state handler. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub new { |
|
42
|
48
|
|
|
48
|
1
|
179415
|
my ($class, %options) = @_; |
|
43
|
|
|
|
|
|
|
|
|
44
|
48
|
|
|
|
|
241
|
return bless { %options }, $class; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 extract |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $session_id = $state->extract($scope); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Extract the session ID from the PAGI scope. Returns the session ID |
|
52
|
|
|
|
|
|
|
string or undef if none is found. Subclasses must implement this. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub extract { |
|
57
|
1
|
|
|
1
|
1
|
18
|
my ($self, $scope) = @_; |
|
58
|
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
9
|
die ref($self) . " must implement extract()"; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head2 inject |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
$state->inject(\@headers, $id, \%options); |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Inject the session ID into the response by pushing header arrayrefs |
|
67
|
|
|
|
|
|
|
onto the provided headers array. Subclasses must implement this. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub inject { |
|
72
|
1
|
|
|
1
|
1
|
20
|
my ($self, $headers, $id, $options) = @_; |
|
73
|
|
|
|
|
|
|
|
|
74
|
1
|
|
|
|
|
7
|
die ref($self) . " must implement inject()"; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 clear |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$state->clear(\@headers); |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Clear the client-side session state (e.g., expire a cookie). Called |
|
82
|
|
|
|
|
|
|
when a session is destroyed. The default implementation is a no-op, |
|
83
|
|
|
|
|
|
|
suitable for state handlers where the client manages transport |
|
84
|
|
|
|
|
|
|
(Header, Bearer). Cookie-based state handlers should override this |
|
85
|
|
|
|
|
|
|
to emit an expired Set-Cookie header. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub clear { |
|
90
|
1
|
|
|
1
|
1
|
10
|
my ($self, $headers) = @_; |
|
91
|
|
|
|
|
|
|
# Default: no-op (Header/Bearer don't need to clear anything) |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__END__ |