| 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
| |||||||||||||
| 12 | # set default values | ||||||||||||
| 13 | 6 | ▶ | $args{session_id_name} ||= 'sid'; | ||||||||||
|
Condition50%1/2
$args{"session_id_name"} ||= "sid"
MC/DC0%0/1
$args{"session_id_name"} ||= "sid"
$args{"session_id_name"}
Truth table50%1/2
A
A= $args{"session_id_name"}
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 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__ | ||||||||||||