| 1 | package Uniform::HTTP::Message; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 12 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 12 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 12 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 12 | our $VERSION = '0.06'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 12 | my $TOKEN_RE = qr/\A[!\#\$%&'*+\-.\^_`|~0-9A-Za-z]+\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 255 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=10 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 255 | my ($class, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 255 | my $args = _named_args('new', @args); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 255 | for my $name (keys %$args) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 156 | ▶ | croak "unknown constructor option '$name'" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%9/9
$name eq "version" or $name eq "headers" or $name eq "trailers" or $name eq "body"
$name eq "version" or $name eq "headers" or $name eq "trailers"
$name eq "version" or $name eq "headers"
MC/DC100%4/4
$name eq "version" or $name eq "headers" or $name eq "trailers" or $name eq "body"
$name eq "version"
$name eq "headers"
$name eq "trailers"
$name eq "body"
Truth table100%5/5
A or B or C or D
A= $name eq "version"B= $name eq "headers"C= $name eq "trailers"D= $name eq "body"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | unless $name eq 'version' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | || $name eq 'headers' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | || $name eq 'trailers' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | || $name eq 'body'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 254 | my $self = bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | version => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | headers => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | trailers => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | initial_frozen => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | trailers_frozen => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | body => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | has_buffered_body => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | complete => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | mutable => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 254 | ▶ | $self->version($args->{version}) if exists $args->{version}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 253 | ▶ | $self->_set_initial_headers($args->{headers}) if exists $args->{headers}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 250 | ▶ | $self->_set_initial_trailers($args->{trailers}) if exists $args->{trailers}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 201 | ▶ | $self->body($args->{body}) if exists $args->{body}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 200 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 109 | ▶ | sub version { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 109 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 109 | ▶ | return $self->{version} unless @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 53 | ▶ | croak 'version() accepts at most one value' unless @args == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 53 | $self->_assert_initial_mutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 44 | ▶ | if (!defined $args[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 11 | $self->{version} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 11 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 33 | my $version = _byte_string('version', $args[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 33 | ▶ | croak 'version must contain digits with an optional decimal part' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | unless $version =~ /\A[0-9]+(?:\.[0-9]+)?\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 32 | $self->{version} = $version; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 32 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 39 | ▶ | sub header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header: called CC=10 SCAR=23.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 39 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 39 | ▶ | croak 'header() requires a field name' unless @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 39 | ▶ | croak 'header() accepts a field name and optional value' unless @args <= 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 39 | my $name = _field_name('header', $args[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 39 | my $key = _ascii_lc($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 39 | ▶ | if (@args == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 29 | for my $field (@{ $self->{headers} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 30 | ▶ | return $field->[1] if _ascii_lc($field->[0]) eq $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 10 | $self->_assert_initial_mutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 3 | my $value = _field_value('header', $args[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 3 | my @headers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | my $inserted; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 3 | for my $field (@{ $self->{headers} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 4 | ▶ | if (_ascii_lc($field->[0]) eq $key) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | ▶ | if (!$inserted) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 1 | push @headers, [ $name, $value ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | $inserted = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 2 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 2 | push @headers, [ @$field ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 3 | ▶ | push @headers, [ $name, $value ] unless $inserted; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 3 | $self->{headers} = \@headers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 5 | ▶ | sub header_values { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header_values: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 5 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 5 | ▶ | croak 'header_values() requires exactly one field name' unless @args == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 5 | my $key = _ascii_lc(_field_name('header', $args[0])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 7 | map { $_->[1] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 15 | grep { _ascii_lc($_->[0]) eq $key } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 5 | @{ $self->{headers} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 6 | ▶ | sub add_header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_header: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 6 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 6 | ▶ | croak 'add_header() requires exactly a field name and value' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | unless @args == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 6 | $self->_assert_initial_mutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | push @{ $self->{headers} }, [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | _field_name('header', $args[0]), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | _field_value('header', $args[1]), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 5 | ▶ | sub remove_header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_header: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 5 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 5 | ▶ | croak 'remove_header() requires exactly one field name' unless @args == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 5 | $self->_assert_initial_mutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 1 | my $key = _ascii_lc(_field_name('header', $args[0])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | $self->{headers} = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 2 | map { [ @$_ ] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 4 | grep { _ascii_lc($_->[0]) ne $key } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 1 | @{ $self->{headers} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 25 | ▶ | sub header_count { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header_count: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 25 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 25 | ▶ | croak 'header_count() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 25 | return scalar @{ $self->{headers} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 6 | ▶ | sub header_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header_name: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 6 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 6 | ▶ | croak 'header_name() requires exactly one index' unless @args == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 6 | my $index = _field_index('header', $args[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 5 | ▶ | return if $index >= @{ $self->{headers} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 4 | return $self->{headers}[$index][0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | ▶ | sub header_value { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header_value: called CC=3 SCAR=11.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | ▶ | croak 'header_value() requires exactly one index' unless @args == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | my $index = _field_index('header', $args[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | ▶ | return if $index >= @{ $self->{headers} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 1 | return $self->{headers}[$index][1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 64 | ▶ | sub trailer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trailer: called CC=10 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 64 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 64 | ▶ | croak 'trailer() requires a field name' unless @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 63 | ▶ | croak 'trailer() accepts a field name and optional value' unless @args <= 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 62 | my $name = _field_name('trailer', $args[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 62 | my $key = _ascii_lc($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 62 | ▶ | if (@args == 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 17 | for my $field (@{ $self->{trailers} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 28 | ▶ | return $field->[1] if _ascii_lc($field->[0]) eq $key; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 9 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 45 | $self->_assert_trailers_mutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 41 | my $value = _field_value('trailer', $args[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 6 | my @trailers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | my $inserted; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 6 | for my $field (@{ $self->{trailers} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 18 | ▶ | if (_ascii_lc($field->[0]) eq $key) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 6 | ▶ | if (!$inserted) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 3 | push @trailers, [ $name, $value ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 3 | $inserted = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 6 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 12 | push @trailers, [ @$field ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 6 | ▶ | push @trailers, [ $name, $value ] unless $inserted; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 6 | $self->{trailers} = \@trailers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 6 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 90 | ▶ | sub trailer_values { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trailer_values: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 90 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 90 | ▶ | croak 'trailer_values() requires exactly one field name' unless @args == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 88 | my $key = _ascii_lc(_field_name('trailer', $args[0])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 90 | map { $_->[1] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 108 | grep { _ascii_lc($_->[0]) eq $key } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 88 | @{ $self->{trailers} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 56 | ▶ | sub add_trailer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_trailer: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 56 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 56 | ▶ | croak 'add_trailer() requires exactly a field name and value' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | unless @args == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 55 | $self->_assert_trailers_mutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 47 | push @{ $self->{trailers} }, [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | _field_name('trailer', $args[0]), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | _field_value('trailer', $args[1]), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 12 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 12 | ▶ | sub remove_trailer { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_trailer: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 12 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 12 | ▶ | croak 'remove_trailer() requires exactly one field name' unless @args == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 10 | $self->_assert_trailers_mutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 6 | my $key = _ascii_lc(_field_name('trailer', $args[0])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | $self->{trailers} = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 12 | map { [ @$_ ] } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 18 | grep { _ascii_lc($_->[0]) ne $key } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 6 | @{ $self->{trailers} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 6 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 34 | ▶ | sub trailer_count { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trailer_count: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 34 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 34 | ▶ | croak 'trailer_count() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 33 | return scalar @{ $self->{trailers} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 35 | ▶ | sub trailer_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trailer_name: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 35 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 35 | ▶ | croak 'trailer_name() requires exactly one index' unless @args == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 34 | my $index = _field_index('trailer', $args[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 28 | ▶ | return if $index >= @{ $self->{trailers} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 21 | return $self->{trailers}[$index][0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 23 | ▶ | sub trailer_value { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trailer_value: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 23 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 23 | ▶ | croak 'trailer_value() requires exactly one index' unless @args == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 22 | my $index = _field_index('trailer', $args[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 16 | ▶ | return if $index >= @{ $self->{trailers} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 9 | return $self->{trailers}[$index][1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 22 | ▶ | sub body { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
body: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 22 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 22 | ▶ | return $self->{body} unless @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 13 | ▶ | croak 'body() accepts at most one value' unless @args == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 13 | $self->_assert_mutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 9 | ▶ | croak 'buffered body is immutable' unless $self->body_is_mutable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 8 | $self->{body} = _byte_string('body', $args[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 7 | $self->{has_buffered_body} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 7 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 8 | ▶ | sub has_buffered_body { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_buffered_body: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 8 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 8 | ▶ | croak 'has_buffered_body() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 8 | ▶ | return $self->{has_buffered_body} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 116 | ▶ | sub is_complete { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_complete: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 116 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 116 | ▶ | croak 'is_complete() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 116 | ▶ | return $self->{complete} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 1236 | ▶ | sub is_mutable { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_mutable: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 1236 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 1236 | ▶ | croak 'is_mutable() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 1236 | ▶ | return $self->{mutable} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 483 | ▶ | sub initial_is_mutable { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
initial_is_mutable: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 483 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 483 | ▶ | croak 'initial_is_mutable() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 481 | ▶ | return $self->is_mutable && !$self->{initial_frozen} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->is_mutable and not $self->{"initial_frozen"}
MC/DC100%2/2
$self->is_mutable and not $self->{"initial_frozen"}
$self->is_mutable
not $self->{"initial_frozen"}
Truth table100%3/3
A and not(B)
A= $self->is_mutableB= not $self->{"initial_frozen"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 18 | ▶ | sub body_is_mutable { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
body_is_mutable: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 18 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 18 | ▶ | croak 'body_is_mutable() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 16 | ▶ | return $self->is_mutable ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 118 | ▶ | sub trailers_are_mutable { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trailers_are_mutable: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 118 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 118 | ▶ | croak 'trailers_are_mutable() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 116 | ▶ | return $self->is_mutable && !$self->{trailers_frozen} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->is_mutable and not $self->{"trailers_frozen"}
MC/DC100%2/2
$self->is_mutable and not $self->{"trailers_frozen"}
$self->is_mutable
not $self->{"trailers_frozen"}
Truth table100%3/3
A and not(B)
A= $self->is_mutableB= not $self->{"trailers_frozen"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 9 | ▶ | sub freeze_initial { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
freeze_initial: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 9 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 9 | ▶ | croak 'freeze_initial() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 7 | $self->{initial_frozen} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 7 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 10 | ▶ | sub freeze_trailers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
freeze_trailers: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 10 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 10 | ▶ | croak 'freeze_trailers() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 8 | $self->{trailers_frozen} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 8 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 25 | ▶ | sub freeze { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
freeze: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 25 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 25 | ▶ | croak 'freeze() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 25 | $self->{mutable} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 25 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 9 | ▶ | sub mark_incomplete { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mark_incomplete: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 9 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 9 | ▶ | croak 'mark_incomplete() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 9 | $self->{complete} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 9 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 6 | ▶ | sub mark_complete { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mark_complete: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 6 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 6 | ▶ | croak 'mark_complete() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 6 | $self->{complete} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 6 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 1 | ▶ | sub headers_are_lossless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
headers_are_lossless: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 1 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 1 | ▶ | croak 'headers_are_lossless() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 15 | ▶ | sub has_trailers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_trailers: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 15 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 15 | ▶ | croak 'has_trailers() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 14 | my $count = $self->trailer_count; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 14 | ▶ | return unless defined $count; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 13 | ▶ | return $count ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 7 | ▶ | sub trailers_are_lossless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
trailers_are_lossless: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 7 | my ($self, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 7 | ▶ | croak 'trailers_are_lossless() does not accept arguments' if @args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 6 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 50 | ▶ | sub _set_initial_headers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_initial_headers: called CC=5 SCAR=16.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 50 | my ($self, $headers) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 50 | ▶ | croak 'headers must be an array reference of field-name/value pairs' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | unless ref($headers) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 49 | my @copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 49 | for my $field (@$headers) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 90 | ▶ | croak 'each header must be a two-element array reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $field eq "ARRAY" and @$field == 2
MC/DC0%0/2
ref $field eq "ARRAY" and @$field == 2
ref $field eq "ARRAY"
@$field == 2
Truth table33%1/3
A and B
A= ref $field eq "ARRAY"B= @$field == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | unless ref($field) eq 'ARRAY' && @$field == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 90 | push @copy, [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | _field_name('header', $field->[0]), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | _field_value('header', $field->[1]), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 47 | $self->{headers} = \@copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 47 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 58 | ▶ | sub _set_initial_trailers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_initial_trailers: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 58 | my ($self, $trailers) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 58 | ▶ | croak 'trailers must be an array reference of field-name/value pairs' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | unless ref($trailers) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 55 | my @copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 55 | for my $field (@$trailers) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 61 | ▶ | croak 'each trailer must be a two-element array reference' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $field eq "ARRAY" and @$field == 2
MC/DC100%2/2
ref $field eq "ARRAY" and @$field == 2
ref $field eq "ARRAY"
@$field == 2
Truth table100%3/3
A and B
A= ref $field eq "ARRAY"B= @$field == 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | unless ref($field) eq 'ARRAY' && @$field == 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 57 | push @copy, [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | _field_name('trailer', $field->[0]), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | _field_value('trailer', $field->[1]), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 9 | $self->{trailers} = \@copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 9 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 622 | ▶ | sub _assert_mutable { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_assert_mutable: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 622 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 622 | ▶ | croak 'message is immutable' unless $self->is_mutable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 583 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 499 | ▶ | sub _assert_initial_mutable { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_assert_initial_mutable: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 499 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 499 | $self->_assert_mutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 471 | ▶ | croak 'initial message data is immutable' unless $self->initial_is_mutable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 453 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 110 | ▶ | sub _assert_trailers_mutable { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_assert_trailers_mutable: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 110 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 110 | $self->_assert_mutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 103 | ▶ | croak 'trailers are immutable' unless $self->trailers_are_mutable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 94 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 444 | ▶ | sub _named_args { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_named_args: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 444 | my ($method, @args) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 444 | ▶ | croak "$method() requires named arguments" if @args % 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 444 | return { @args }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 936 | ▶ | sub _byte_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_byte_string: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 936 | my ($name, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 936 | ▶ | croak "$name must be a defined plain scalar" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $value and not ref $value
MC/DC100%2/2
defined $value and not ref $value
defined $value
not ref $value
Truth table100%3/3
A and not(B)
A= defined $valueB= not ref $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | unless defined($value) && !ref($value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 926 | my $copy = "$value"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 926 | ▶ | croak "$name must be a byte string" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | unless utf8::downgrade($copy, 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 919 | return $copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 397 | ▶ | sub _field_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_field_name: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 397 | my ($section, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 397 | my $name = _byte_string("$section name", $value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 394 | ▶ | croak "$section name must be an HTTP token" unless $name =~ $TOKEN_RE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 389 | return $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 232 | ▶ | sub _field_value { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_field_value: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 232 | my ($section, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 232 | my $field_value = _byte_string("$section value", $value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 223 | ▶ | croak "$section value contains a prohibited control byte" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | if $field_value =~ /[\x00-\x08\x0a-\x1f\x7f]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 126 | return $field_value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 63 | ▶ | sub _field_index { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_field_index: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 63 | my ($section, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 63 | ▶ | croak "$section index must be a non-negative integer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $value and not ref $value and $value =~ /\A[0-9]+\z/
defined $value and not ref $value
MC/DC100%3/3
defined $value and not ref $value and $value =~ /\A[0-9]+\z/
defined $value
not ref $value
$value =~ /\A[0-9]+\z/
Truth table100%4/4
A and not(B) and C
A= defined $valueB= not ref $valueC= $value =~ /\A[0-9]+\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | unless defined($value) && !ref($value) && $value =~ /\A[0-9]+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 50 | return 0 + $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 426 | ▶ | sub _ascii_lc { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_ascii_lc: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 426 | my ($value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 426 | $value =~ tr/A-Z/a-z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 426 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 12 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||