line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Amon2::Plugin::Web::HTTPSession; |
2
|
1
|
|
|
1
|
|
905
|
use 5.008005; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
51
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
57
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "5.04"; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
960
|
use HTTP::Session; |
|
1
|
|
|
|
|
9596
|
|
|
1
|
|
|
|
|
13
|
|
9
|
1
|
|
|
1
|
|
1128
|
use Amon2::Util; |
|
1
|
|
|
|
|
21174
|
|
|
1
|
|
|
|
|
49
|
|
10
|
1
|
|
|
1
|
|
794
|
use Plack::Util (); |
|
1
|
|
|
|
|
11996
|
|
|
1
|
|
|
|
|
27
|
|
11
|
1
|
|
|
1
|
|
787
|
use Plack::Request; |
|
1
|
|
|
|
|
76116
|
|
|
1
|
|
|
|
|
459
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub init { |
14
|
0
|
|
|
0
|
0
|
|
my ($class, $c, $conf) = @_; |
15
|
|
|
|
|
|
|
|
16
|
0
|
0
|
|
|
|
|
my $state_conf = $conf->{state} or die "missing configuration : state"; |
17
|
0
|
0
|
|
|
|
|
my $store_conf = $conf->{store} or die "missing configuration : store"; |
18
|
0
|
|
|
|
|
|
my $state_code = $class->_load($state_conf, 'HTTP::Session::State'); |
19
|
0
|
|
|
|
|
|
my $store_code = $class->_load($store_conf, 'HTTP::Session::Store'); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Amon2::Util::add_method($c, session => sub { |
22
|
0
|
|
|
0
|
|
|
my $self = shift; |
23
|
0
|
|
0
|
|
|
|
$self->{+__PACKAGE__} ||= do { |
24
|
0
|
|
|
|
|
|
HTTP::Session->new( |
25
|
|
|
|
|
|
|
state => $state_code->($self), |
26
|
|
|
|
|
|
|
store => $store_code->($self), |
27
|
|
|
|
|
|
|
# Note: Do not decode session id |
28
|
|
|
|
|
|
|
request => Plack::Request->new($self->request->env), |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
}; |
31
|
0
|
|
|
|
|
|
}); |
32
|
|
|
|
|
|
|
$c->add_trigger(AFTER_DISPATCH => sub { |
33
|
0
|
|
|
0
|
|
|
my ($self, $res) = @_; |
34
|
0
|
0
|
|
|
|
|
if (my $session = $self->{+__PACKAGE__}) { |
35
|
0
|
|
|
|
|
|
$session->response_filter($res); |
36
|
0
|
|
|
|
|
|
$session->finalize(); |
37
|
|
|
|
|
|
|
} |
38
|
0
|
|
|
|
|
|
}); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _load { |
42
|
0
|
|
|
0
|
|
|
my ($class, $stuff, $namespace) = @_; |
43
|
0
|
0
|
|
|
|
|
if (ref $stuff) { |
44
|
0
|
0
|
|
|
|
|
if (ref $stuff eq 'CODE') { |
45
|
0
|
|
|
|
|
|
return $stuff; |
46
|
|
|
|
|
|
|
} else { |
47
|
0
|
|
|
0
|
|
|
return sub { $stuff }; |
|
0
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} else { |
50
|
0
|
|
|
|
|
|
my $store_class = Plack::Util::load_class($stuff, $namespace); |
51
|
0
|
|
|
|
|
|
my $store_obj; |
52
|
|
|
|
|
|
|
return sub { |
53
|
0
|
|
0
|
0
|
|
|
$store_obj ||= do { |
54
|
0
|
|
0
|
|
|
|
my $config ||= Amon2->context->config->{$store_class} || {}; |
|
|
|
0
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$store_class->new($config); |
56
|
|
|
|
|
|
|
}; |
57
|
0
|
|
|
|
|
|
}; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |
63
|
|
|
|
|
|
|
__END__ |