| 1 | package Cake::Engine; | ||||||||||||||||||||||||||||
| 2 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 8 | ▶ | use IO::File; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 8 | ▶ | use File::Temp qw/ tempfile tempdir /; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | sub init { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 9 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 10 | 2 | ▶ | my $uri = $self->env->{'REQUEST_URI'} || ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->env->{'REQUEST_URI'} || ''
MC/DC0%0/1
$self->env->{'REQUEST_URI'} || ''
$self->env->{'REQUEST_URI'}
Truth table50%1/2
A
A= $self->env->{'REQUEST_URI'}
| |||||||||||||||||||||||||||||
| 11 | 2 | my($path, $query) = ( $uri =~ /^([^?]*)(?:\?(.*))?$/s ); | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | ##remove script name from path info | ||||||||||||||||||||||||||||
| 14 | 2 | ▶ | my $script = $self->env->{SCRIPT_NAME} || ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
$self->env->{'SCRIPT_NAME'} || ''
MC/DC0%0/1
$self->env->{'SCRIPT_NAME'} || ''
$self->env->{'SCRIPT_NAME'}
Truth table50%1/2
A
A= $self->env->{'SCRIPT_NAME'}
| |||||||||||||||||||||||||||||
| 15 | 2 | $path =~ s/^$script//; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | #for ($path, $query) { s/\#.*$// if length } # dumb clients sending URI fragments | ||||||||||||||||||||||||||||
| 18 | 2 | $self->env->{PATH_INFO} = Cake::URI::uri_decode($path); | |||||||||||||||||||||||||||
| 19 | 2 | ▶ | $self->env->{QUERY_STRING} = $query || ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
$query || ''
MC/DC0%0/1
$query || ''
$query
Truth table50%1/2
A
A= $query
| |||||||||||||||||||||||||||||
| 20 | 2 | $self->engine(bless {}, __PACKAGE__); | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | #BEGIN { open (STDERR, ">>/xampp/htdocs/CakeBlog/error.txt"); } | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | #============================================================================= | ||||||||||||||||||||||||||||
| 26 | # finalize output | ||||||||||||||||||||||||||||
| 27 | #============================================================================= | ||||||||||||||||||||||||||||
| 28 | 3 | ▶ | sub finalize { | ||||||||||||||||||||||||||
|
Subroutine
finalize: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 29 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 30 | 3 | $self->printConsole(); | |||||||||||||||||||||||||||
| 31 | 3 | return $self; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | #============================================================================= | ||||||||||||||||||||||||||||
| 35 | # console debugging | ||||||||||||||||||||||||||||
| 36 | #============================================================================= | ||||||||||||||||||||||||||||
| 37 | 3 | ▶ | sub printConsole { | ||||||||||||||||||||||||||
|
Subroutine
printConsole: called CC=11 SCAR=46.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 38 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 39 | 3 | ▶ | return if !$self->debug; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | ▶ | if (my $logs = $self->app->{log}){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | my $debug = "\n=======================\n"; | |||||||||||||||||||||||||||
| 43 | 0 | $debug .= " DEBUGGING CONSOLE ||\n"; | |||||||||||||||||||||||||||
| 44 | 0 | $debug .= _charFormatter('='); | |||||||||||||||||||||||||||
| 45 | 0 | $debug .= "REQUEST PATH : ".$self->path . "\n"; | |||||||||||||||||||||||||||
| 46 | 0 | $debug .= "REQUEST METHOD : ".$self->method . "\n"; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | ##log request params | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | $debug .= _charFormatter('#'); | |||||||||||||||||||||||||||
| 51 | 0 | $debug .= _charFormatter(' '); | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 0 | my $i = 0; | |||||||||||||||||||||||||||
| 54 | 0 | foreach my $log (@{$logs}){ | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if (ref $log eq "ARRAY"){ | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 57 | 0 | $log = join "\n",@{$log}; | |||||||||||||||||||||||||||
| 58 | } elsif (ref $log eq 'CODE') { | ||||||||||||||||||||||||||||
| 59 | 0 | $log = $log->(); | |||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | ▶ | if (length($log) > 65){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 0 | my @logs = unpack("(A62)*", $log); | |||||||||||||||||||||||||||
| 64 | 0 | my $last = pop @logs; | |||||||||||||||||||||||||||
| 65 | 0 | foreach my $lo (@logs){ | |||||||||||||||||||||||||||
| 66 | 0 | $lo .= "->"; | |||||||||||||||||||||||||||
| 67 | 0 | $debug .= _printFormatter($lo); | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | 0 | $log = $last; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 0 | $debug .= _printFormatter($log); | |||||||||||||||||||||||||||
| 73 | 0 | $debug .= _charFormatter(' '); | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | 0 | $debug .= _charFormatter('#'); | |||||||||||||||||||||||||||
| 76 | 0 | warn $debug."\n"; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | if (my $warnings = delete $self->app->{warnings}){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 80 | 8 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 81 | 0 | my $warn = "\n=======================\n"; | |||||||||||||||||||||||||||
| 82 | 0 | $warn .= " WARNING CONSOLE ||\n"; | |||||||||||||||||||||||||||
| 83 | 0 | $warn .= _charFormatter('='); | |||||||||||||||||||||||||||
| 84 | 0 | my $count = 0; | |||||||||||||||||||||||||||
| 85 | 0 | foreach my $key (keys %{$warnings}){ | |||||||||||||||||||||||||||
| 86 | 0 | $warn .= _charFormatter('-'); | |||||||||||||||||||||||||||
| 87 | 0 | $warn .= "CALLER => ". $key . "\n"; | |||||||||||||||||||||||||||
| 88 | 0 | $warn .= "WARNS => ". scalar @{ $warnings->{$key} } . "\n"; | |||||||||||||||||||||||||||
| 89 | 0 | $warn .= _charFormatter('-'); | |||||||||||||||||||||||||||
| 90 | 0 | for (@{ $warnings->{$key} }){ | |||||||||||||||||||||||||||
| 91 | 0 | $count++; | |||||||||||||||||||||||||||
| 92 | 0 | $warn .= "Message: ". $_->{message} ."\n"; | |||||||||||||||||||||||||||
| 93 | 0 | $warn .= "Line: ". $_->{line} ."\n\n"; | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 0 | $warn .= "\n"; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | 0 | $warn .= _charFormatter('#'); | |||||||||||||||||||||||||||
| 100 | 0 | my $str = "# TOTAL WARNINGS : $count "; | |||||||||||||||||||||||||||
| 101 | 0 | $warn .= _printFormatter($str); | |||||||||||||||||||||||||||
| 102 | 0 | $warn .= _charFormatter('#'); | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 0 | warn $warn; | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | 0 | $self->app->{log} = []; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 0 | ▶ | sub _printFormatter { | ||||||||||||||||||||||||||
|
Subroutine
_printFormatter: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 110 | 0 | my $text = shift; | |||||||||||||||||||||||||||
| 111 | 0 | ▶ | my $padd = shift || ' '; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || ' '
MC/DC0%0/1
shift() || ' '
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 112 | 0 | my $form .= "$text"; | |||||||||||||||||||||||||||
| 113 | 0 | $form .= $padd x (64 - length($text)) . "#\n"; | |||||||||||||||||||||||||||
| 114 | 0 | return $form; | |||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 0 | ▶ | sub _charFormatter { | ||||||||||||||||||||||||||
|
Subroutine
_charFormatter: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 118 | 0 | my $char = shift; | |||||||||||||||||||||||||||
| 119 | 0 | ▶ | my $multi = shift || 64; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 64
MC/DC0%0/1
shift() || 64
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 120 | 0 | return ($char x $multi) . "#\n"; | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | #============================================================================= | ||||||||||||||||||||||||||||
| 124 | # serve output | ||||||||||||||||||||||||||||
| 125 | #============================================================================= | ||||||||||||||||||||||||||||
| 126 | 3 | ▶ | sub serve { | ||||||||||||||||||||||||||
|
Subroutine
serve: called CC=4 SCAR=17.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 129 | 3 | my $type = shift; | |||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 3 | ▶ | if ($type){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | 3 | ▶ | return $self->serve_as_psgi if uc $type eq 'PSGI'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 133 | 3 | ▶ | if (ref $type eq 'CODE'){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 134 | 3 | return $type->($self,$self->env->{client}); | |||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | 0 | $self->Require($type,''); | |||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | { | ||||||||||||||||||||||||||||
| 139 | 0 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||
| 140 | 0 | *{"${type}::serve"}->($self); | |||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | else { | ||||||||||||||||||||||||||||
| 145 | 0 | $self->print_headers(); | |||||||||||||||||||||||||||
| 146 | 0 | $self->print_body(); | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 0 | close $self->{response}->{body}; | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | #============================================================================= | ||||||||||||||||||||||||||||
| 155 | # get parameters | ||||||||||||||||||||||||||||
| 156 | #============================================================================= | ||||||||||||||||||||||||||||
| 157 | 0 | ▶ | sub get_parameters { | ||||||||||||||||||||||||||
|
Subroutine
get_parameters: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 158 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 159 | 0 | return $self->_parse_parameters($self->env->{'QUERY_STRING'}); | |||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | #============================================================================= | ||||||||||||||||||||||||||||
| 163 | # body parameters | ||||||||||||||||||||||||||||
| 164 | #============================================================================= | ||||||||||||||||||||||||||||
| 165 | 0 | ▶ | sub post_parameters { | ||||||||||||||||||||||||||
|
Subroutine
post_parameters: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 166 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 167 | 0 | my $buffer; | |||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 0 | ▶ | return {} if $self->method ne 'post'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 0 | ▶ | if (my $tt = ($self->env->{'client.input'} || $self->env->{'psgi.input'})){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->env->{'client.input'} || $self->env->{'psgi.input'}
MC/DC0%0/2
$self->env->{'client.input'} || $self->env->{'psgi.input'}
$self->env->{'client.input'}
$self->env->{'psgi.input'}
Truth table0%0/3
A || B
A= $self->env->{'client.input'}B= $self->env->{'psgi.input'}
| |||||||||||||||||||||||||||||
| 172 | { | ||||||||||||||||||||||||||||
| 173 | 0 | local $/; | |||||||||||||||||||||||||||
| 174 | 0 | $buffer = <$tt>; | |||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | ##CGI | ||||||||||||||||||||||||||||
| 178 | else { | ||||||||||||||||||||||||||||
| 179 | 0 | read( STDIN, $buffer, $self->env->{ "CONTENT_LENGTH" } ); | |||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 0 | ▶ | if ($self->env->{CONTENT_TYPE} =~ /^multipart\/form-data/i){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 0 | $self->env->{CONTENT_TYPE} =~ m/boundary=(.*)/; | |||||||||||||||||||||||||||
| 184 | 0 | my $boundary = $1; | |||||||||||||||||||||||||||
| 185 | 0 | return $self->_multipart_parameters($buffer,$boundary); | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | 0 | return $self->_parse_parameters($buffer); | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | #============================================================================= | ||||||||||||||||||||||||||||
| 192 | # process multipart body parameters | ||||||||||||||||||||||||||||
| 193 | #============================================================================= | ||||||||||||||||||||||||||||
| 194 | 0 | ▶ | sub _multipart_parameters { | ||||||||||||||||||||||||||
|
Subroutine
_multipart_parameters: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 197 | 0 | my $params = shift; | |||||||||||||||||||||||||||
| 198 | 0 | my $boundary = shift; | |||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 0 | my $CRLF = $self->crlf; | |||||||||||||||||||||||||||
| 201 | 0 | $boundary = '--'.$boundary; | |||||||||||||||||||||||||||
| 202 | 0 | $params =~ s/$CRLF$boundary--//g; | |||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 0 | my @params = split($boundary.$CRLF,$params); | |||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 0 | my @query; | |||||||||||||||||||||||||||
| 207 | my $handle; | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | 0 | for my $field (@params){ | |||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | ##remove first line | ||||||||||||||||||||||||||||
| 212 | 0 | $field =~ s/^$CRLF//; | |||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | ##remove last blank | ||||||||||||||||||||||||||||
| 215 | 0 | $field =~ s/$CRLF$//; | |||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | ##split on first 2 line breaks | ||||||||||||||||||||||||||||
| 218 | 0 | my ($header,$content) = split(/$CRLF$CRLF/,$field,2); | |||||||||||||||||||||||||||
| 219 | 0 | ▶ | next if !$header; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | ##split header on line break | ||||||||||||||||||||||||||||
| 222 | 0 | my ($name,$filename,$contenttype) = | |||||||||||||||||||||||||||
| 223 | $header =~ m/ | ||||||||||||||||||||||||||||
| 224 | name="?([^\";]*)"? | ||||||||||||||||||||||||||||
| 225 | (?:;\s+filename="?([^\"]*)"?$CRLF)? | ||||||||||||||||||||||||||||
| 226 | (?:Content-Type:(.*))? | ||||||||||||||||||||||||||||
| 227 | /x; | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 0 | ▶ | if($filename){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 231 | #make sure the file name is safe | ||||||||||||||||||||||||||||
| 232 | 0 | my $dir = tempdir( CLEANUP => 1 ); | |||||||||||||||||||||||||||
| 233 | 0 | my ($fh, $tmp) = tempfile( | |||||||||||||||||||||||||||
| 234 | DIR => $dir, | ||||||||||||||||||||||||||||
| 235 | SUFFIX => '.dat' | ||||||||||||||||||||||||||||
| 236 | ); | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | 0 | $fh->unlink_on_destroy( 1 ); | |||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 0 | ▶ | if (defined $fh) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 241 | 0 | binmode $fh, ":utf8"; | |||||||||||||||||||||||||||
| 242 | 0 | print $fh $content; | |||||||||||||||||||||||||||
| 243 | 0 | $fh->close; | |||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | 0 | $self->{uploads}->{$name} = { | |||||||||||||||||||||||||||
| 247 | 'filehandle' => $fh, | ||||||||||||||||||||||||||||
| 248 | 'filename' => $filename, | ||||||||||||||||||||||||||||
| 249 | temp => $tmp, | ||||||||||||||||||||||||||||
| 250 | 'path' => $dir, | ||||||||||||||||||||||||||||
| 251 | 'content-type' => $contenttype | ||||||||||||||||||||||||||||
| 252 | }; | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 0 | $content = $filename; | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 0 | push(@query,$name.'='.Cake::URI::uri_encode($content)); | |||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | 0 | my $query = join('&',@query); | |||||||||||||||||||||||||||
| 261 | 0 | return $self->_parse_parameters($query); | |||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | #============================================================================= | ||||||||||||||||||||||||||||
| 265 | # XXX - TODO return uploads info & file handle | ||||||||||||||||||||||||||||
| 266 | #============================================================================= | ||||||||||||||||||||||||||||
| 267 | 0 | ▶ | sub uploads { | ||||||||||||||||||||||||||
|
Subroutine
uploads: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | #didn't parse params yet | ||||||||||||||||||||||||||||
| 272 | 0 | ▶ | unless (defined $self->{'params'}){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 273 | 0 | $self->parameters(); | |||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | 0 | ▶ | return {} if !$self->{uploads}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 277 | 0 | return $self->{uploads}; | |||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 0 | ▶ | sub upload { | ||||||||||||||||||||||||||
|
Subroutine
upload: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 281 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 282 | 0 | my $name = shift; | |||||||||||||||||||||||||||
| 283 | 0 | return $self->uploads->{$name}; | |||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | #============================================================================= | ||||||||||||||||||||||||||||
| 288 | # return processed parameters | ||||||||||||||||||||||||||||
| 289 | #============================================================================= | ||||||||||||||||||||||||||||
| 290 | 0 | ▶ | sub parameters { | ||||||||||||||||||||||||||
|
Subroutine
parameters: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 291 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 292 | 0 | ▶ | return $self->{'params'} if $self->{'params'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 293 | 0 | my $params = Cake::Utils::combineHashes($self->get_parameters,$self->post_parameters); | |||||||||||||||||||||||||||
| 294 | 0 | $self->{'params'} = $params; | |||||||||||||||||||||||||||
| 295 | 0 | return $params; | |||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | #============================================================================= | ||||||||||||||||||||||||||||
| 299 | # parse parameters | ||||||||||||||||||||||||||||
| 300 | #============================================================================= | ||||||||||||||||||||||||||||
| 301 | 0 | ▶ | sub _parse_parameters { | ||||||||||||||||||||||||||
|
Subroutine
_parse_parameters: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||
| 303 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 304 | 0 | my $content = shift; | |||||||||||||||||||||||||||
| 305 | 0 | my $params = {}; | |||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | 0 | my @pairs = split(/[&;]/, $content); | |||||||||||||||||||||||||||
| 308 | 0 | foreach my $pair (@pairs) { | |||||||||||||||||||||||||||
| 309 | 0 | my ($name, $value) = map Cake::URI::uri_decode($_), split( "=", $pair, 2 ); | |||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | 0 | ▶ | if ($name =~ s/\[(\d+)\]\[(.*?)\]//){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 312 | 0 | my $index = $1; | |||||||||||||||||||||||||||
| 313 | 0 | my $n = $2; | |||||||||||||||||||||||||||
| 314 | 0 | ▶ | if (!ref $params->{$name}){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 315 | 0 | $params->{$name} = []; | |||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||
| 317 | 0 | $params->{$name}->[$index]->{$n} = $value; | |||||||||||||||||||||||||||
| 318 | } else { | ||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | 0 | ▶ | if ($name =~ s/\[\]$// && !ref $params->{$name}){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$name =~ s/\[\]$// and not ref $params->{$name}
MC/DC0%0/2
$name =~ s/\[\]$// and not ref $params->{$name}
$name =~ s/\[\]$//
not ref $params->{$name}
Truth table0%0/3
A and not(B)
A= $name =~ s/\[\]$//B= not ref $params->{$name}
| |||||||||||||||||||||||||||||
| 321 | 0 | $params->{$name} = []; | |||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | 0 | ▶ | if ($params->{$name}){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 325 | 0 | ▶ | if (!ref $params->{$name}){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 326 | 0 | my $holds = [$params->{$name},$value]; | |||||||||||||||||||||||||||
| 327 | 0 | $params->{$name} = $holds; | |||||||||||||||||||||||||||
| 328 | } else { | ||||||||||||||||||||||||||||
| 329 | 0 | push (@{$params->{$name}},$value); | |||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||
| 331 | } else { | ||||||||||||||||||||||||||||
| 332 | 0 | $params->{$name} = $value; | |||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | 0 | return $params; | |||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | #serve content as psgi | ||||||||||||||||||||||||||||
| 341 | 0 | ▶ | sub serve_as_psgi { | ||||||||||||||||||||||||||
|
Subroutine
serve_as_psgi: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||
| 343 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | 0 | my @headers = $self->_get_psgi_headers; | |||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | 0 | my $body = $self->body(); | |||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | 0 | ▶ | seek($body,0,0) if ref $body eq 'GLOB'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | 0 | ▶ | if (!ref $body){ | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 352 | 0 | $body = [ $body ]; | |||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | elsif (ref $body eq 'CODE'){ | ||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 358 | 0 | my $response = shift; | |||||||||||||||||||||||||||
| 359 | 0 | my $w = $response->([ $self->status_code(), \@headers ]); | |||||||||||||||||||||||||||
| 360 | 0 | $body->($w); | |||||||||||||||||||||||||||
| 361 | 0 | }; | |||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | 0 | return $body; | |||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||
| 366 | 0 | return [ $self->status_code, \@headers, $body ]; | |||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | 0 | ▶ | sub _get_psgi_headers { | ||||||||||||||||||||||||||
|
Subroutine
_get_psgi_headers: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 370 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 371 | 0 | my @headers = ('Content-Type',$self->content_type); | |||||||||||||||||||||||||||
| 372 | 0 | foreach my $header (@{$self->headers}){ | |||||||||||||||||||||||||||
| 373 | 0 | my @nh = split(/:/,$header,2); | |||||||||||||||||||||||||||
| 374 | 0 | push (@headers,@nh); | |||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||
| 376 | 0 | return @headers; | |||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | 0 | ▶ | sub print_headers { | ||||||||||||||||||||||||||
|
Subroutine
print_headers: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 380 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 381 | 0 | my $headers; | |||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | ##normal print/ for CGI | ||||||||||||||||||||||||||||
| 384 | 0 | my $content_type_header = 'Content-Type: '.$self->content_type; | |||||||||||||||||||||||||||
| 385 | 0 | my $status_code = 'Status-code: '.$self->status_code; | |||||||||||||||||||||||||||
| 386 | 0 | $headers = Cake::Utils::get_status_code($self->env,$self->status_code); | |||||||||||||||||||||||||||
| 387 | 0 | $headers .= "$content_type_header\015\012"; | |||||||||||||||||||||||||||
| 388 | 0 | my $found_content_length; | |||||||||||||||||||||||||||
| 389 | 0 | foreach my $header (@{$self->headers}){ | |||||||||||||||||||||||||||
| 390 | 0 | $headers .= $header."\015\012"; | |||||||||||||||||||||||||||
| 391 | 0 | ▶ | $found_content_length = 1 | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$header =~ /^Content-Length/i and not $found_content_length
MC/DC0%0/2
$header =~ /^Content-Length/i and not $found_content_length
$header =~ /^Content-Length/i
not $found_content_length
Truth table0%0/3
A and not(B)
A= $header =~ /^Content-Length/iB= not $found_content_length
| |||||||||||||||||||||||||||||
| 392 | if $header =~ /^Content-Length/i && !$found_content_length; | ||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | 0 | ▶ | unless ($found_content_length){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 396 | 0 | my $body = $self->body(); | |||||||||||||||||||||||||||
| 397 | 0 | ▶ | $headers .= "Content-Length: ".Cake::Utils::content_length($body)."\015\012" if $body; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | 0 | $headers .= "\015\012"; | |||||||||||||||||||||||||||
| 401 | 0 | my $stdout = $self->stdout; | |||||||||||||||||||||||||||
| 402 | 0 | print $stdout $headers; | |||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | 0 | ▶ | sub print_body { | ||||||||||||||||||||||||||
|
Subroutine
print_body: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 406 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 407 | 0 | my $body = $self->body(); | |||||||||||||||||||||||||||
| 408 | 0 | my $stdout = $self->stdout; | |||||||||||||||||||||||||||
| 409 | 0 | binmode $stdout; | |||||||||||||||||||||||||||
| 410 | 0 | ▶ | if (ref $body eq 'GLOB'){ | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 411 | ##seek to the start | ||||||||||||||||||||||||||||
| 412 | 0 | seek($body,0,0); | |||||||||||||||||||||||||||
| 413 | 0 | local $/ = undef; | |||||||||||||||||||||||||||
| 414 | 0 | $body = <$body>; | |||||||||||||||||||||||||||
| 415 | 0 | print $stdout $body; | |||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | elsif (ref $body eq 'CODE'){ | ||||||||||||||||||||||||||||
| 419 | 0 | $body->(__PACKAGE__); | |||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||
| 421 | } | ||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | #============================================================================= | ||||||||||||||||||||||||||||
| 424 | # ENV | ||||||||||||||||||||||||||||
| 425 | #============================================================================= | ||||||||||||||||||||||||||||
| 426 | 4 | ▶ | sub path { | ||||||||||||||||||||||||||
|
Subroutine
path: called CC=3 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 427 | 4 | ▶ | if (@_ > 1){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 428 | 0 | $_[0]->env->{PATH_INFO} = $_[1]; | |||||||||||||||||||||||||||
| 429 | 0 | return $_[0]; | |||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||
| 431 | 4 | ▶ | return $_[0]->env->{PATH_INFO} || '/'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$_[0]->env->{'PATH_INFO'} || '/'
MC/DC0%0/1
$_[0]->env->{'PATH_INFO'} || '/'
$_[0]->env->{'PATH_INFO'}
Truth table50%1/2
A
A= $_[0]->env->{'PATH_INFO'}
| |||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | 3 | ▶ | sub method { | ||||||||||||||||||||||||||
|
Subroutine
method: called CC=3 SCAR=13.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 435 | 3 | ▶ | if (@_ > 1){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 436 | 0 | $_[0]->env->{REQUEST_METHOD} = $_[1]; | |||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||
| 438 | 3 | ▶ | return lc ($_[0]->env->{REQUEST_METHOD} || ''); | ||||||||||||||||||||||||||
|
Condition50%1/2
$_[0]->env->{'REQUEST_METHOD'} || ''
MC/DC0%0/1
$_[0]->env->{'REQUEST_METHOD'} || ''
$_[0]->env->{'REQUEST_METHOD'}
Truth table50%1/2
A
A= $_[0]->env->{'REQUEST_METHOD'}
| |||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | 0 | ▶ | sub is_secure { | ||||||||||||||||||||||||||
|
Subroutine
is_secure: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 442 | 0 | ▶ | return $_[0]->env->{'SSL_PROTOCOL'} ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||
| 445 | 0 | ▶ | sub base { | ||||||||||||||||||||||||||
|
Subroutine
base: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 446 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 447 | 0 | my $base = 'http'; | |||||||||||||||||||||||||||
| 448 | 0 | ▶ | $base .='s' if $self->is_secure(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 449 | 0 | $base .= '://'.$self->env->{HTTP_HOST}; | |||||||||||||||||||||||||||
| 450 | 0 | return $base; | |||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | 0 | ▶ | sub host { | ||||||||||||||||||||||||||
|
Subroutine
host: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 454 | 0 | return $_[0]->env->{HTTP_HOST}; | |||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | 0 | ▶ | sub server_protocol { | ||||||||||||||||||||||||||
|
Subroutine
server_protocol: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 458 | 0 | ▶ | return shift->env->{SERVER_PROTOCOL} || 'HTTP/1.1'; | ||||||||||||||||||||||||||
|
Condition0%0/2
+(shift())->env->{'SERVER_PROTOCOL'} || 'HTTP/1.1'
MC/DC0%0/1
+(shift())->env->{'SERVER_PROTOCOL'} || 'HTTP/1.1'
+(shift())->env->{'SERVER_PROTOCOL'}
Truth table0%0/2
A
A= +(shift())->env->{'SERVER_PROTOCOL'}
| |||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | 0 | ▶ | sub request_header { | ||||||||||||||||||||||||||
|
Subroutine
request_header: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 464 | 0 | my $header = uc shift; | |||||||||||||||||||||||||||
| 465 | 0 | my $response_headers = { | |||||||||||||||||||||||||||
| 466 | 'ETAG' => 'IF-NONE-MATCH' | ||||||||||||||||||||||||||||
| 467 | }; | ||||||||||||||||||||||||||||
| 468 | 0 | $header =~ s/^(HTTP[-_])//; | |||||||||||||||||||||||||||
| 469 | 0 | $header =~ s/[-\s]/_/g; | |||||||||||||||||||||||||||
| 470 | 0 | ▶ | $header = $response_headers->{$header} || $header; | ||||||||||||||||||||||||||
|
Condition0%0/3
$response_headers->{$header} || $header
MC/DC0%0/2
$response_headers->{$header} || $header
$response_headers->{$header}
$header
Truth table0%0/3
A || B
A= $response_headers->{$header}B= $header
| |||||||||||||||||||||||||||||
| 471 | 0 | $header = 'HTTP_'.$header; | |||||||||||||||||||||||||||
| 472 | 0 | return $self->env->{$header}; | |||||||||||||||||||||||||||
| 473 | } | ||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | 0 | ▶ | sub stdout { | ||||||||||||||||||||||||||
|
Subroutine
stdout: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 476 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 477 | 0 | ▶ | if (@_){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 478 | 0 | $self->env->{client} = shift; | |||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||
| 480 | 0 | ▶ | return $self->env->{client} || \*STDOUT; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->env->{'client'} || \*STDOUT
MC/DC0%0/1
$self->env->{'client'} || \*STDOUT
$self->env->{'client'}
Truth table0%0/2
A
A= $self->env->{'client'}
| |||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | #============================================================================= | ||||||||||||||||||||||||||||
| 484 | # cookies : return cookies list as hash - copied from plack | ||||||||||||||||||||||||||||
| 485 | #============================================================================= | ||||||||||||||||||||||||||||
| 486 | 0 | ▶ | sub cookies { | ||||||||||||||||||||||||||
|
Subroutine
cookies: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 487 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 488 | 0 | ▶ | return {} unless $self->env->{HTTP_COOKIE}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||
| 490 | # HTTP_COOKIE hasn't changed: reuse the parsed cookie | ||||||||||||||||||||||||||||
| 491 | 0 | ▶ | if ( $self->env->{'cake.cookie.parsed'} | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->env->{"cake.cookie.parsed"} and $self->env->{"cake.cookie.string"} eq $self->env->{"HTTP_COOKIE"}
MC/DC0%0/2
$self->env->{"cake.cookie.parsed"} and $self->env->{"cake.cookie.string"} eq $self->env->{"HTTP_COOKIE"}
$self->env->{"cake.cookie.parsed"}
$self->env->{"cake.cookie.string"} eq $self->env->{"HTTP_COOKIE"}
Truth table0%0/3
A and B
A= $self->env->{"cake.cookie.parsed"}B= $self->env->{"cake.cookie.string"} eq $self->env->{"HTTP_COOKIE"}
| |||||||||||||||||||||||||||||
| 492 | && $self->env->{'cake.cookie.string'} eq $self->env->{HTTP_COOKIE}) { | ||||||||||||||||||||||||||||
| 493 | 0 | return $self->env->{'cake.cookie.parsed'}; | |||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||
| 496 | 0 | $self->env->{'cake.cookie.string'} = $self->env->{HTTP_COOKIE}; | |||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||
| 498 | 0 | my %results; | |||||||||||||||||||||||||||
| 499 | 0 | my @pairs = grep /=/, split "[;,] ?", $self->env->{'cake.cookie.string'}; | |||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||
| 501 | 0 | for my $pair ( @pairs ) { | |||||||||||||||||||||||||||
| 502 | # trim leading trailing whitespace | ||||||||||||||||||||||||||||
| 503 | 0 | $pair =~ s/^\s+//; $pair =~ s/\s+$//; | |||||||||||||||||||||||||||
| 504 | #my ($key, $value) = split( "=", $pair, 2 ); | ||||||||||||||||||||||||||||
| 505 | 0 | my ($key, $value) = map Cake::URI::uri_decode($_), split( "=", $pair, 2 ); | |||||||||||||||||||||||||||
| 506 | # Take the first one like CGI.pm or rack do | ||||||||||||||||||||||||||||
| 507 | 0 | ▶ | $results{$key} = $value unless exists $results{$key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||
| 510 | 0 | $self->env->{'cake.cookie.parsed'} = \%results; | |||||||||||||||||||||||||||
| 511 | 0 | return \%results; | |||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||
| 514 | #============================================================================= | ||||||||||||||||||||||||||||
| 515 | # set/get a cookie | ||||||||||||||||||||||||||||
| 516 | #============================================================================= | ||||||||||||||||||||||||||||
| 517 | 0 | ▶ | sub cookie { | ||||||||||||||||||||||||||
|
Subroutine
cookie: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 518 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||
| 520 | 0 | ▶ | if (ref $_[0] eq 'HASH'){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 521 | 0 | my $args = shift; | |||||||||||||||||||||||||||
| 522 | 0 | ▶ | my $name = Cake::URI::uri_encode($args->{name} || ref $self->app); | ||||||||||||||||||||||||||
|
Condition0%0/3
$args->{'name'} || ref $self->app
MC/DC0%0/2
$args->{'name'} || ref $self->app
$args->{'name'}
ref $self->app
Truth table0%0/3
A || B
A= $args->{'name'}B= ref $self->app
| |||||||||||||||||||||||||||||
| 523 | 0 | ▶ | my $value = Cake::URI::uri_encode($args->{value} || ''); | ||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'value'} || ''
MC/DC0%0/1
$args->{'value'} || ''
$args->{'value'}
Truth table0%0/2
A
A= $args->{'value'}
| |||||||||||||||||||||||||||||
| 524 | 0 | ▶ | my $secure = $args->{secure} || '0'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'secure'} || '0'
MC/DC0%0/1
$args->{'secure'} || '0'
$args->{'secure'}
Truth table0%0/2
A
A= $args->{'secure'}
| |||||||||||||||||||||||||||||
| 525 | 0 | ▶ | my $path = $args->{path} || '/'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$args->{'path'} || '/'
MC/DC0%0/1
$args->{'path'} || '/'
$args->{'path'}
Truth table0%0/2
A
A= $args->{'path'}
| |||||||||||||||||||||||||||||
| 526 | 0 | my $time = ''; | |||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||
| 528 | 0 | ▶ | if ($args->{length}){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 529 | 0 | my $length = Cake::Utils::to_epoch($args->{length}); | |||||||||||||||||||||||||||
| 530 | 0 | $time = gmtime($length)." GMT"; | |||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | 0 | my $cookie = "$name=$value; path=$path; expires=$time; $secure"; | |||||||||||||||||||||||||||
| 534 | 0 | $self->push_header('Set-Cookie: '.$cookie); | |||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||
| 537 | 0 | ▶ | croak 'cookie method only accepts Hash ref for setting and string for getting' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $_[0] or @_ > 1
MC/DC0%0/2
ref $_[0] or @_ > 1
ref $_[0]
@_ > 1
Truth table0%0/3
A or B
A= ref $_[0]B= @_ > 1
| |||||||||||||||||||||||||||||
| 538 | if ref $_[0] || @_ > 1; | ||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | 0 | ▶ | my $name = shift || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 541 | 0 | return $self->cookies->{$name}; | |||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||
| 544 | 8 | 1; | |||||||||||||||||||||||||||