| 1 | package Plack::Middleware::CookieMonster; | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | our $VERSION = '0.03'; | |||||||||||||||||||||||||||
| 6 | 1 | $VERSION = eval $VERSION; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use parent qw/ Plack::Middleware /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Plack::Util::Accessor qw( cookie_names path ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Plack::Request; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 5 | ▶ | sub call { | ||||||||||||||||||||||||||
|
Subroutine
call: called CC=5 SCAR=16.3
Pod
documented
| |||||||||||||||||||||||||||||
| 15 | 5 | my ( $self, $env ) = @_; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 5 | my $res = $self->app->( $env ); | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 5 | ▶ | if ( $env->{ 'plack.stacktrace.html' } && $res->[ 0 ] == 500 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$env->{"plack.stacktrace.html"} and $res->[0] == 500
MC/DC0%0/2
$env->{"plack.stacktrace.html"} and $res->[0] == 500
$env->{"plack.stacktrace.html"}
$res->[0] == 500
Truth table33%1/3
A and B
A= $env->{"plack.stacktrace.html"}B= $res->[0] == 500
| |||||||||||||||||||||||||||||
| 20 | 5 | my @cookies = $self->_get_cookie_names( $env ); | |||||||||||||||||||||||||||
| 21 | 5 | my $path = ''; | |||||||||||||||||||||||||||
| 22 | 5 | ▶ | if ( defined $self->path ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 23 | 2 | $path = sprintf 'path=%s; ', $self->path; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | 5 | my $fmt = sprintf '%%s=deleted; %sExpires=Sat, 01-May-1971 04:30:01 GMT', $path; | |||||||||||||||||||||||||||
| 26 | 5 | foreach my $cookie ( @cookies ) { | |||||||||||||||||||||||||||
| 27 | 5 | push @{ $res->[ 1 ] }, 'Set-Cookie', sprintf $fmt, $cookie; | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 5 | return $res; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 15 | ▶ | sub _get_cookie_names { | ||||||||||||||||||||||||||
|
Subroutine
_get_cookie_names: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 35 | 15 | my ( $self, $env ) = @_; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 15 | my $sent = Plack::Request->new( $env )->cookies; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 15 | ▶ | if ( my $cookie_names = $self->cookie_names ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 10 | return grep { $sent->{ $_ } } @$cookie_names; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | else { | ||||||||||||||||||||||||||||
| 43 | 5 | return keys %$sent; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 1 | 1; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | __END__ | ||||||||||||||||||||||||||||