Branch Coverage

blib/lib/CGI/Tiny.pm
Criterion Covered Total %
branch 280 358 78.2


line true false branch
102 0 75 if (@ARGV and not defined $ENV{'REQUEST_METHOD'})
109 8 65 unless (eval { do { local $_ = $cgi; &$handler(); 1 } })
111 8 65 if ($errored) { }
20 45 elsif (not $cgi->{'headers_rendered'}) { }
124 5 2 if (defined $cgi)
125 5 0 unless $cgi->{'headers_rendered'}
133 1 32 unless $cgi->{'pid'} == $$
135 22 9 unless $cgi->{'headers_rendered'} or defined $cgi->{'response_status'} and $cgi->{'response_status'} =~ /^[45][0-9]{2} /
136 30 2 if (defined(my $handler = $cgi->{'on_error'})) { }
140 0 30 unless (eval { do { &$handler($cgi, $error, !!$cgi->{'headers_rendered'}); 1 } })
142 0 30 unless $cgi->{'pid'} == $$
143 0 30 if ($error_errored)
150 31 1 unless $cgi->{'headers_rendered'}
161 1 0 defined $ENV{'AUTH_TYPE'} ? :
162 1 0 defined $ENV{'CONTENT_LENGTH'} ? :
163 1 0 defined $ENV{'CONTENT_TYPE'} ? :
164 1 0 defined $ENV{'GATEWAY_INTERFACE'} ? :
165 2 0 defined $ENV{'PATH_INFO'} ? :
167 1 0 defined $ENV{'PATH_TRANSLATED'} ? :
168 5 0 defined $ENV{'QUERY_STRING'} ? :
170 1 0 defined $ENV{'REMOTE_ADDR'} ? :
171 1 0 defined $ENV{'REMOTE_HOST'} ? :
172 1 0 defined $ENV{'REMOTE_IDENT'} ? :
173 1 0 defined $ENV{'REMOTE_USER'} ? :
174 2 0 defined $ENV{'REQUEST_METHOD'} ? :
176 1 0 defined $ENV{'SCRIPT_NAME'} ? :
177 1 0 defined $ENV{'SERVER_NAME'} ? :
178 1 0 defined $ENV{'SERVER_PORT'} ? :
179 1 0 defined $ENV{'SERVER_PROTOCOL'} ? :
180 1 0 defined $ENV{'SERVER_SOFTWARE'} ? :
184 1 0 unless (exists $self->{'request_headers'})
188 51 3 unless $name =~ s/^HTTP_//
201 1 1 exists $$c{$_[1]} ? :
202 1 0 exists $$c{$_[1]} ? :
206 1 4 unless (exists $self->{'request_cookies'})
208 1 0 if (defined $ENV{'HTTP_COOKIE'})
210 0 4 unless length $pair
212 0 4 unless defined $value
213 3 1 unless exists $keyed{$name}
227 1 2 if exists $p->{$name}
229 1 1 exists $q->{$name} ? :
231 4 2 exists $$_{$_[1]} ? :
235 1 1 exists $$p{$_[1]} ? :
236 1 1 exists $$p{$_[1]} ? :
240 3 10 unless (exists $self->{'query_params'})
244 0 10 unless defined $value
246 8 2 unless exists $keyed{$name}
256 6 0 unless (exists $self->{'body_content'} or exists $self->{'body_parts'})
259 5 0 defined $self->{'input_handle'} ? :
263 5 0 $length < $buffer_size ? :
264 0 5 unless my $read = read($in_fh, $self->{'body_content'}, $chunk, length $self->{'body_content'})
273 3 1 unless (exists $self->{'body_json'})
275 2 1 if ($ENV{'CONTENT_TYPE'} and $ENV{'CONTENT_TYPE'} =~ m[^application/json\b]i)
284 7 1 exists $$p{$_[1]} ? :
285 5 1 exists $$p{$_[1]} ? :
289 9 28 unless (exists $self->{'body_params'})
291 2 7 if ($ENV{'CONTENT_TYPE'} and $ENV{'CONTENT_TYPE'} =~ m[^application/x-www-form-urlencoded\b]i) { }
6 2 elsif ($ENV{'CONTENT_TYPE'} and $ENV{'CONTENT_TYPE'} =~ m[^multipart/form-data\b]i) { }
294 0 8 unless defined $value
296 6 2 unless exists $keyed{$name}
302 1 5 unless defined $default_charset
304 8 10 if defined $part->{'filename'}
306 10 0 if (length $default_charset)
311 9 1 if (defined $content) { }
1 0 elsif (defined $file) { }
320 5 5 if (defined $headers->{'content-type'})
321 5 0 if (my($charset_quoted, $charset_unquoted) = $headers->{'content-type'} =~ /;\s*charset=(?:"((?:\\[\\"]|[^"])+)"|([^";]+))/i)
322 0 5 if defined $charset_quoted
323 0 5 defined $charset_quoted ? :
326 5 0 if (defined $value_charset or not defined $headers->{'content-type'} or $headers->{'content-type'} =~ m[^text/plain\b]i)
328 5 5 if (defined $value_charset) { }
5 0 elsif (length $default_charset) { }
334 8 2 unless exists $keyed{$name}
345 1 8 unless $ENV{'CONTENT_TYPE'} and $ENV{'CONTENT_TYPE'} =~ m[^multipart/form-data\b]i
351 6 1 exists $$u{$_[1]} ? :
352 5 1 exists $$u{$_[1]} ? :
356 6 19 unless (exists $self->{'body_uploads'})
358 6 0 if ($ENV{'CONTENT_TYPE'} and $ENV{'CONTENT_TYPE'} =~ m[^multipart/form-data\b]i)
360 1 5 unless defined $default_charset
362 10 8 unless defined $part->{'filename'}
364 8 0 if (length $default_charset)
374 5 3 if defined $file
375 1 7 if defined $content
376 7 1 unless exists $keyed{$name}
388 11 1 unless defined $limit
389 11 1 unless defined $limit
391 1 11 if ($limit and $length > $limit)
392 1 0 unless $self->{'headers_rendered'}
400 8 12 unless (exists $self->{'body_parts'})
404 1 7 unless (defined $boundary)
405 1 0 unless $self->{'headers_rendered'}
410 1 6 if (exists $self->{'body_content'}) { }
415 6 0 defined $self->{'input_handle'} ? :
420 2 5 unless $self->{'multipart_form_options'}
422 1 6 unless (defined $parts)
423 1 0 unless $self->{'headers_rendered'}
434 0 2 if ($self->{'headers_rendered'}) { }
437 1 1 @_ < 2 ? :
446 0 15 if ($self->{'headers_rendered'}) { }
449 1 14 if (defined $status and $status =~ /\A[0-9]+ [^\r\n]*\z/) { }
14 0 elsif (defined $status) { }
452 1 13 unless exists $HTTP_STATUS{$status}
465 0 4 if ($self->{'headers_rendered'}) { }
468 0 4 unless exists $DISPOSITIONS{lc $disposition}
479 0 36 if ($self->{'headers_rendered'}) { }
482 0 36 if defined $content_type and $content_type =~ tr/\n\r//
490 0 2 if defined $charset and $charset =~ /[^a-zA-Z0-9!#\$%&'*+\-.^_`|~]/
497 0 4 if ($self->{'headers_rendered'}) { }
500 0 4 if $value =~ tr/\n\r//
510 0 3 if ($self->{'headers_rendered'}) { }
518 0 10 if (not defined $has_value) { }
6 4 elsif ($has_value) { }
521 6 0 if defined $val
523 2 2 if $val
528 0 3 if $cookie_str =~ tr/\n\r//
539 15 0 if (defined $self->{'response_status'} and $self->{'response_status'} =~ /\A([0-9]+)/)
550 0 65 if $self->{'headers_rendered'}
551 22 43 unless defined $type
552 0 65 if length $type and not exists $RENDER_TYPES{$type}
553 0 65 if $type eq 'handle'
556 3 62 if ($type eq 'redirect') { }
1 61 elsif (uc($ENV{'REQUEST_METHOD'} || '') eq 'HEAD') { }
5 56 elsif ($type eq 'text' or $type eq 'html' or $type eq 'xml') { }
1 55 elsif ($type eq 'json') { }
32 23 elsif ($type eq 'data') { }
1 22 elsif ($type eq 'file') { }
557 0 3 if $data =~ tr/\n\r//
563 4 1 unless defined $charset
564 4 1 if (uc $charset eq 'UTF-8' and do { local $@; eval { do { require Unicode::UTF8; 1 } } }) { }
579 0 1 unless defined $response_length
581 26 39 unless defined $response_length
584 63 2 defined $self->{'output_handle'} ? :
589 27 38 unless $response_length
591 1 37 if ($type eq 'file') { }
592 0 1 unless open my $in_fh, '<', $data
607 0 17 if $self->{'response_fixed_length'}
608 5 12 unless defined $type
609 0 17 if length $type and not exists $RENDER_TYPES{$type}
610 0 17 if $type eq 'redirect'
612 17 0 defined $self->{'output_handle'} ? :
613 12 5 unless ($self->{'headers_rendered'})
620 2 15 if (uc($ENV{'REQUEST_METHOD'} || '') eq 'HEAD') { }
4 11 elsif ($type eq 'text' or $type eq 'html' or $type eq 'xml') { }
2 9 elsif ($type eq 'json') { }
2 7 elsif ($type eq 'data') { }
2 5 elsif ($type eq 'file' or $type eq 'handle') { }
624 3 1 unless defined $charset
626 3 1 if (uc $charset eq 'UTF-8' and do { local $@; eval { do { require Unicode::UTF8; 1 } } }) { }
640 1 1 if ($type eq 'file') { }
641 0 1 unless open $in_fh, '<', $data
659 0 77 if defined $self->{'debug_method'} and not $self->{'debug_verbose'}
661 76 1 unless $self->{'response_headers'}
666 65 12 if (not $headers_set{'content-length'} and defined $content_length)
669 3 74 if (not $headers_set{'content-disposition'} and defined $self->{'response_disposition'} || defined $self->{'response_filename'})
670 3 0 defined $self->{'response_disposition'} ? :
671 2 1 if (defined(my $filename = $self->{'response_filename'}))
681 2 1 unless lc $value eq 'inline'
683 3 74 if (not $headers_set{'location'} and $type eq 'redirect')
686 74 3 if (not $headers_set{'content-type'} and $type ne 'redirect')
689 72 2 unless defined $charset
690 1 11 $type eq 'json' ? :
1 12 $type eq 'xml' ? :
2 13 $type eq 'html' ? :
3 15 $type eq 'text' ? :
18 22 unless defined $content_type or defined $content_length and $content_length == 0
697 52 22 if defined $content_type
699 77 0 unless ($headers_set{'date'})
704 2 75 if $type eq 'redirect' and not defined $status && $status =~ /^3[0-9]{2} /
706 2 75 if ($self->{'nph'}) { }
37 38 elsif (not $headers_set{'status'} and defined $status) { }
707 1 1 unless defined $status
709 0 2 unless defined $protocol and length $protocol
712 1 1 if defined $server and length $server
721 3 2 unless (exists $self->{'json'})
722 3 0 if (do { local $@; eval { do { require Cpanel::JSON::XS; 'Cpanel::JSON::XS'->VERSION('4.09'); 1 } } }) { }
752 3 16 unless defined $mday
757 2 17 unless defined $mday
761 1 18 unless defined $mday
766 0 18 length $year == 4 && $year < 1900 ? :