Session/State/URI.pm

filter: Statementstmt 96.9% 32 / 33 Branchbran 62.5% 5 / 8 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 8 / 8 Podpod 100% 4 / 4 totaltotal 89.2% 50 / 56 CC 6 SCAR 6.9
CC
6
Cov
88%
new
3.3
redirect_filter
2.0
html_filter
2.0
CRAP 2.0
« Session/Store/OnMemory.pm ↑ Summary Session/ID/Urandom.pm »
1 package HTTP::Session::State::URI;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use HTTP::Session::State::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use HTML::StickyQuery;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use HTTP::Session::State::Mixin::ResponseFilter qw/response_filter/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 3 __PACKAGE__->mk_ro_accessors(qw/session_id_name/);
8  
9 6 ▶sub new {
Subroutine new: called CC=3 SCAR=12.0
Pod documented
10 6 my $class = shift;
11 0 ▶ my %args = ref($_[0]) ? %{$_[0]} : @_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 6 6
12 # set default values
13 6 ▶ $args{session_id_name} ||= 'sid';
Condition50%1/2
$args{"session_id_name"} ||= "sid"
l!l
06
MC/DC0%0/1
$args{"session_id_name"} ||= "sid"
$args{"session_id_name"}
Truth table50%1/2
A
A= $args{"session_id_name"}
Aresult
11
00
14 6 bless {%args}, $class;
15 }
16  
17 6 ▶sub get_session_id {
Subroutine get_session_id: called CC=2 SCAR=6.9
Pod documented
18 6 my ($self, $req) = @_;
19 6 ▶ Carp::croak "missing req" unless $req;
Branch: 1 branch
BranchTrueFalseTotal
unless $req 1 5 6
20 5 $req->param($self->session_id_name); # hmm... this is not support psgi.
21 }
22  
23 4 ▶sub html_filter {
Subroutine html_filter: called CC=2 SCAR=7.0
Pod documented
24 4 my ($self, $session_id, $html) = @_;
25 4 ▶ Carp::croak "missing session_id" unless $session_id;
Branch: 1 branch
BranchTrueFalseTotal
unless $session_id 0 4 4
26  
27 4 my $session_id_name = $self->session_id_name;
28  
29 4 $html =~ s{(<form\s*.*?>)}{$1\n<input type="hidden" name="$session_id_name" value="$session_id" />}isg;
30  
31 4 my $sticky = HTML::StickyQuery->new;
32 4 return $sticky->sticky(
33 scalarref => \$html,
34 param => { $session_id_name => $session_id },
35 );
36 }
37  
38 3 ▶sub redirect_filter {
Subroutine redirect_filter: called CC=2 SCAR=7.0
Pod documented
39 3 my ( $self, $session_id, $path ) = @_;
40 3 ▶ Carp::croak "missing session_id" unless $session_id;
Branch: 1 branch
BranchTrueFalseTotal
unless $session_id 0 3 3
41  
42 3 my $uri = URI->new($path);
43 3 $uri->query_form( $uri->query_form, $self->session_id_name => $session_id );
44 3 return $uri->as_string;
45 }
46  
47 3 1;
48 __END__
« Session/Store/OnMemory.pm ↑ Summary Session/ID/Urandom.pm »