Branch Coverage

blib/lib/HTTP/Message.pm
Criterion Covered Total %
branch 291 312 93.2


line true false branch
26 3 194 unless utf8::downgrade($_[0], 1)
36 85 70 if (defined $header) { }
37 1 84 unless ref $header
38 63 21 if (ref $header eq 'ARRAY') { }
48 80 74 if (defined $content) { }
68 29 36 if ($str =~ s/^([^\s:]+)[ \t]*: ?(.*)\n?//) { }
5 31 elsif (@hdr and $str =~ s/^([ \t].*)\n?//) { }
114 3 1122 unless exists $self->{'_content'}
127 197 91 if (defined wantarray)
128 6 191 unless exists $self->{'_content'}
130 5 192 if ref $old eq "SCALAR"
131 6 191 if @_ > 1
135 89 2 if (@_ > 1) { }
139 1 1 if $^W
147 3 101 if (not ref $_[1] and ref $self->{'_content'} eq 'SCALAR') { }
148 3 0 defined $_[1] ? :
151 1 100 if ref $_[1] eq "SCALAR"
152 98 2 defined $_[1] ? :
155 92 10 unless $_[2]
162 0 12 unless exists $self->{'_content'}
164 2 10 if ref $$chunkref
169 9 2 if (not $ref) { }
1 1 elsif ($ref eq 'SCALAR') { }
191 0 137 unless exists $self->{'_content'}
195 6 131 if (@_)
197 1 5 unless ref $new
202 6 130 if $old_cref
210 1 51 if (my $charset = $self->content_type_charset)
219 2 49 if /^\xEF\xBB\xBF/
220 1 48 if /^\xFF\xFE\x00\x00/
221 1 47 if /^\x00\x00\xFE\xFF/
222 4 43 if /^\xFF\xFE/
223 1 42 if /^\xFE\xFF/
226 15 27 if ($self->content_is_xml) { }
4 23 elsif ($self->content_is_html) { }
6 17 elsif ($self->content_type eq 'application/json') { }
232 1 14 if /^\x00\x00\x00
233 1 13 if /^<\x00\x00\x00/
234 1 12 if /^(?:\x00\s)*\x00
235 1 11 if /^(?:\s\x00)*<\x00/
236 4 7 if (/^\s*(<\?xml[^\x00]*?\?>)/)
237 4 0 if ($1 =~ /\sencoding\s*=\s*(["'])(.*?)\1/)
240 3 1 if $enc
253 3 1 if $encoding
258 1 5 if /^\x00\x00\x00./s
259 2 3 if /^.\x00\x00\x00/s
260 1 2 if /^\x00.\x00./s
261 1 1 if /^.\x00.\x00/s
265 17 1 if ($self->content_type =~ m[^text/])
267 16 1 if (length $_)
268 13 3 unless /[\x80-\xFF]/
273 2 1 unless $@
285 6 127 if @_ > 1
302 0 118 if ref $content_ref ne "SCALAR"
305 3 112 defined $self->max_body_size ? :
3 115 exists $opt{'max_body_size'} ? :
309 6 112 if (defined $content_limit)
312 60 58 if (my $h = $self->header("Content-Encoding"))
316 0 105 unless $ce
317 4 101 if $ce eq "identity" or $ce eq "none"
318 30 71 if ($ce eq 'gzip' or $ce eq 'x-gzip') { }
12 59 elsif ($ce eq 'br') { }
28 31 elsif ($ce eq 'x-bzip2' or $ce eq 'bzip2') { }
6 25 elsif ($ce eq 'deflate') { }
2 23 elsif ($ce eq 'compress' or $ce eq 'x-compress') { }
19 4 elsif ($ce eq 'base64') { }
1 3 elsif ($ce eq 'quoted-printable') { }
321 2 28 if (not $content_ref_iscopy and keys %limiter_options)
334 2 28 if $res == Compress::Raw::Zlib::Z_BUF_ERROR()
336 0 28 unless $res == Compress::Raw::Zlib::Z_OK() or $res == Compress::Raw::Zlib::Z_STREAM_END()
347 2 10 if (defined $content_limit) { }
353 2 10 if $@
360 12 16 unless ($content_ref_iscopy)
375 4 24 if $limiter_options{'Bufsize'}
377 0 28 if $res == Compress::Raw::Bzip2::BZ_OUTBUFF_FULL()
379 2 26 unless $res == Compress::Raw::Bzip2::BZ_OK() or $res == Compress::Raw::Bzip2::BZ_STREAM_END()
390 2 4 unless ($status)
397 0 2 unless (IO::Uncompress::RawInflate::rawinflate($content_ref, \$output))
403 0 6 unless defined $output
426 98 9 if ($self->content_is_text or my $is_xml = $self->content_is_xml)
434 57 41 if ($charset eq 'none') { }
14 27 elsif ($charset eq 'us-ascii' or $charset eq 'iso-8859-1') { }
438 3 11 if ($$content_ref =~ /[^\x00-\x7F]/ and defined &utf8::upgrade)
439 3 0 unless ($content_ref_iscopy)
451 1 26 $opt{'charset_strict'} ? :
453 4 23 if ($@)
455 3 1 if ($@ =~ /^Unknown encoding/)
457 2 1 if ($alt_charset and $charset ne $alt_charset)
460 0 1 $opt{'charset_strict'} ? :
1 1 unless $alt_charset eq "none"
465 2 2 unless $retried
467 0 25 unless defined $$content_ref
468 10 15 if ($is_xml)
471 4 6 if ($$content_ref =~ /^(\s*<\?xml[^\x00]*?\?>)/)
478 13 105 if ($@)
479 9 4 if $opt{'raise_error'}
483 51 54 $opt{'ref'} ? :
514 2 2 wantarray ? :
521 1 11 unless $self->header("Content-Encoding")
522 10 1 if (defined(my $content = $self->decoded_content("charset", "none")))
535 1 12 if $self->content_type =~ m[^multipart/]
536 1 11 if $self->content_type =~ m[^message/]
538 1 10 unless @enc
542 2 10 if ($encoding eq 'identity' or $encoding eq 'none') { }
2 8 elsif ($encoding eq 'base64') { }
2 6 elsif ($encoding eq 'gzip' or $encoding eq 'x-gzip') { }
1 5 elsif ($encoding eq 'deflate') { }
2 3 elsif ($encoding eq 'x-bzip2' or $encoding eq 'bzip2') { }
1 2 elsif ($encoding eq 'br') { }
1 1 elsif ($encoding eq 'rot13') { }
552 0 2 unless IO::Compress::Gzip::gzip(\$content, \$output, "Minimal", 1)
559 0 1 unless IO::Compress::Deflate::deflate(\$content, \$output)
566 0 2 unless IO::Compress::Bzip2::bzip2(\$content, \$output)
573 0 1 unless eval { do { $output = IO::Compress::Brotli::bro($content) } }
585 2 7 if $h
596 53 20 unless defined $eol
602 9 64 @_ == 1 && length $content && !($content =~ /\n\z/) ? :
616 14 0 unless (ref $content)
618 12 2 unless defined $maxlen
619 1 13 if ($maxlen and length $content > $maxlen * "1.1" + 3)
640 10 4 unless defined $no_content
641 2 12 if ($content eq $no_content) { }
7 5 elsif ($content eq '') { }
651 5 9 if $opt{'preheader'}
653 1 13 if $chopped
656 3 11 if $opt{'prefix'}
658 2 12 unless defined wantarray
669 13 6 if (defined wantarray and !exists $self->{'_parts'} || ref $self->{'_content'} eq 'SCALAR')
673 8 19 if (@_)
674 2 10 ref $_ eq 'ARRAY' ? :
676 3 5 if ($ct =~ m[^message/]) { }
3 2 elsif (not $ct =~ m[^multipart/]) { }
677 1 2 if @parts > 1
687 15 11 if wantarray
693 2 2 if (not +($self->content_type || '') =~ m[^multipart/]) { }
1 1 elsif (not exists $self->{'_parts'} or ref $self->{'_content'} eq 'SCALAR') { }
700 1 1 if ($p->headers->header_field_names or $p->content ne "")
715 1 10 if (ref $self->{'_content'} eq 'SCALAR') { }
732 3 70 unless $code
741 20 105 if (my $own_method = $self->SUPER::can($method))
745 102 3 ref $self ? :
746 72 33 if ($headers->can($method))
769 118 148 if @_
778 4 10 if ($ct =~ m[^multipart/]) { }
4 6 elsif ($ct eq 'message/http') { }
2 4 elsif ($ct =~ m[^message/]) { }
781 0 4 unless @h
783 3 1 if (defined(my $b = $h{'boundary'}))
786 3 0 if ($str =~ s/(^|.*?\r?\n)--\Q$b\E\r?\n//s)
796 2 2 $content =~ m[^(HTTP/.*)\n] ? :
812 2 8 if ($ct =~ m[^\s*message/]i)
819 0 8 if @v > 1
826 2 8 if ($k eq "boundary")
836 6 2 unless defined $boundary
840 1 14 if (index($_, $boundary) >= 0)
848 2 6 if ($boundary_index) { }