| 1 | package HTTP::Headers::Fast; | ||||||||||||||||||||||||||||||||||||||||||
| 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 5.00800; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 8 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 8 | our $VERSION = '0.22'; | |||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 8 | our $TRANSLATE_UNDERSCORE = 1; | |||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | # "Good Practice" order of HTTP message headers: | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # - General-Headers | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # - Request-Headers | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # - Response-Headers | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # - Entity-Headers | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | # yappo says "Readonly sucks". | ||||||||||||||||||||||||||||||||||||||||||
| 18 | 8 | my $OP_GET = 0; | |||||||||||||||||||||||||||||||||||||||||
| 19 | 8 | my $OP_SET = 1; | |||||||||||||||||||||||||||||||||||||||||
| 20 | 8 | my $OP_INIT = 2; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 8 | my $OP_PUSH = 3; | |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 8 | my @general_headers = qw( | |||||||||||||||||||||||||||||||||||||||||
| 24 | Cache-Control Connection Date Pragma Trailer Transfer-Encoding Upgrade | ||||||||||||||||||||||||||||||||||||||||||
| 25 | Via Warning | ||||||||||||||||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | 8 | my @request_headers = qw( | |||||||||||||||||||||||||||||||||||||||||
| 29 | Accept Accept-Charset Accept-Encoding Accept-Language | ||||||||||||||||||||||||||||||||||||||||||
| 30 | Authorization Expect From Host | ||||||||||||||||||||||||||||||||||||||||||
| 31 | If-Match If-Modified-Since If-None-Match If-Range If-Unmodified-Since | ||||||||||||||||||||||||||||||||||||||||||
| 32 | Max-Forwards Proxy-Authorization Range Referer TE User-Agent | ||||||||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 8 | my @response_headers = qw( | |||||||||||||||||||||||||||||||||||||||||
| 36 | Accept-Ranges Age ETag Location Proxy-Authenticate Retry-After Server | ||||||||||||||||||||||||||||||||||||||||||
| 37 | Vary WWW-Authenticate | ||||||||||||||||||||||||||||||||||||||||||
| 38 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 8 | my @entity_headers = qw( | |||||||||||||||||||||||||||||||||||||||||
| 41 | Allow Content-Encoding Content-Language Content-Length Content-Location | ||||||||||||||||||||||||||||||||||||||||||
| 42 | Content-MD5 Content-Range Content-Type Expires Last-Modified | ||||||||||||||||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 8 | my %entity_header = map { lc($_) => 1 } @entity_headers; | |||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 8 | my @header_order = | |||||||||||||||||||||||||||||||||||||||||
| 48 | ( @general_headers, @request_headers, @response_headers, @entity_headers, ); | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | # Make alternative representations of @header_order. This is used | ||||||||||||||||||||||||||||||||||||||||||
| 51 | # for sorting and case matching. | ||||||||||||||||||||||||||||||||||||||||||
| 52 | 8 | my %header_order; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 8 | our %standard_case; | |||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | { | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 8 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 8 | for (@header_order) { | |||||||||||||||||||||||||||||||||||||||||
| 58 | 376 | my $lc = lc $_; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 376 | $header_order{$lc} = ++$i; | |||||||||||||||||||||||||||||||||||||||||
| 60 | 376 | $standard_case{$lc} = $_; | |||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | 29 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 29 | my ($class) = shift; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 29 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 29 | ▶ | $self->header(@_) if @_; # set up initial headers | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 29 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 5 | ▶ | sub isa { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isa: called CC=4 SCAR=14.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 5 | my ($self, $klass) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 5 | ▶ | my $proto = ref $self || $self; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $self || $self
MC/DC0%0/2
ref $self || $self
ref $self
$self
Truth table33%1/3
A || B
A= ref $selfB= $self
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 5 | ▶ | return ($proto eq $klass || $klass eq 'HTTP::Headers') ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$proto eq $klass or $klass eq "HTTP::Headers"
MC/DC100%2/2
$proto eq $klass or $klass eq "HTTP::Headers"
$proto eq $klass
$klass eq "HTTP::Headers"
Truth table100%3/3
A or B
A= $proto eq $klassB= $klass eq "HTTP::Headers"
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 68 | ▶ | sub header { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 68 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 68 | ▶ | Carp::croak('Usage: $h->header($field, ...)') unless @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 67 | my (@old); | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 67 | ▶ | if (@_ == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 30 | @old = $self->_header_get(@_); | |||||||||||||||||||||||||||||||||||||||||
| 84 | } elsif( @_ == 2 ) { | ||||||||||||||||||||||||||||||||||||||||||
| 85 | 21 | @old = $self->_header_set(@_); | |||||||||||||||||||||||||||||||||||||||||
| 86 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 16 | my %seen; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 16 | ▶ | while (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 56 | my $field = shift; | |||||||||||||||||||||||||||||||||||||||||
| 90 | 56 | ▶ | if ( $seen{ lc $field }++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 7 | @old = $self->_header_push($field, shift); | |||||||||||||||||||||||||||||||||||||||||
| 92 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 49 | @old = $self->_header_set($field, shift); | |||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 67 | ▶ | return @old if wantarray; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 59 | ▶ | return $old[0] if @old <= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 8 | join( ", ", @old ); | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 5 | ▶ | sub clear { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 5 | %$self = (); | |||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 6 | ▶ | sub push_header { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
push_header: called CC=11 SCAR=32.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 6 | ▶ | if (@_ == 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 6 | my ($field, $val) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 6 | ▶ | $field = _standardize_field_name($field) unless $field =~ /^:/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | 6 | my $h = $self->{$field}; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 6 | ▶ | if (!defined $h) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | $h = []; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | $self->{$field} = $h; | |||||||||||||||||||||||||||||||||||||||||
| 118 | } elsif (ref $h ne 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 3 | $h = [ $h ]; | |||||||||||||||||||||||||||||||||||||||||
| 120 | 3 | $self->{$field} = $h; | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 6 | ▶ | push @$h, ref $val ne 'ARRAY' ? $val : @$val; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | while ( my ($field, $val) = splice( @_, 0, 2 ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | $field = _standardize_field_name($field) unless $field =~ /^:/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | my $h = $self->{$field}; | |||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | if (!defined $h) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $h = []; | |||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $self->{$field} = $h; | |||||||||||||||||||||||||||||||||||||||||
| 132 | } elsif (ref $h ne 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | $h = [ $h ]; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $self->{$field} = $h; | |||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | push @$h, ref $val ne 'ARRAY' ? $val : @$val; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | 6 | return (); | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | 5 | ▶ | sub init_header { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init_header: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | 5 | ▶ | Carp::croak('Usage: $h->init_header($field, $val)') if @_ != 3; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 4 | shift->_header( @_, $OP_INIT ); | |||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 14 | ▶ | sub remove_header { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_header: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 14 | my ( $self, @fields ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 14 | my $field; | |||||||||||||||||||||||||||||||||||||||||
| 151 | my @values; | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 14 | for my $field (@fields) { | |||||||||||||||||||||||||||||||||||||||||
| 153 | 21 | ▶ | $field =~ tr/_/-/ if $field !~ /^:/ && $TRANSLATE_UNDERSCORE; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $field =~ /^:/ and $HTTP::Headers::Fast::TRANSLATE_UNDERSCORE
MC/DC50%1/2
not $field =~ /^:/ and $HTTP::Headers::Fast::TRANSLATE_UNDERSCORE
not $field =~ /^:/
$HTTP::Headers::Fast::TRANSLATE_UNDERSCORE
Truth table66%2/3
not(A) and B
A= not $field =~ /^:/B= $HTTP::Headers::Fast::TRANSLATE_UNDERSCORE
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 21 | my $v = delete $self->{ lc $field }; | |||||||||||||||||||||||||||||||||||||||||
| 155 | 21 | ▶ | push( @values, ref($v) eq 'ARRAY' ? @$v : $v ) if defined $v; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 14 | return @values; | |||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 3 | ▶ | sub remove_content_headers { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
remove_content_headers: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 3 | ▶ | unless ( defined(wantarray) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||
| 164 | # fast branch that does not create return object | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | ▶ | delete @$self{ grep $entity_header{$_} || /^content-/, keys %$self }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$entity_header{$_} || /^content-/
MC/DC100%2/2
$entity_header{$_} || /^content-/
$entity_header{$_}
/^content-/
Truth table100%3/3
A || B
A= $entity_header{$_}B= /^content-/
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | 2 | my $c = ref($self)->new; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 2 | ▶ | for my $f ( grep $entity_header{$_} || /^content-/, keys %$self ) { | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$entity_header{$_} || /^content-/
MC/DC100%2/2
$entity_header{$_} || /^content-/
$entity_header{$_}
/^content-/
Truth table100%3/3
A || B
A= $entity_header{$_}B= /^content-/
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 10 | $c->{$f} = delete $self->{$f}; | |||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 2 | $c; | |||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 8 | my %field_name; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 148 | ▶ | sub _standardize_field_name { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_standardize_field_name: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 148 | my $field = shift; | |||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 148 | ▶ | $field =~ tr/_/-/ if $TRANSLATE_UNDERSCORE; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 148 | ▶ | if (my $cache = $field_name{$field}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 74 | return $cache; | |||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 74 | my $old = $field; | |||||||||||||||||||||||||||||||||||||||||
| 186 | 74 | $field = lc $field; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 74 | ▶ | unless ( defined $standard_case{$field} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | # generate a %standard_case entry for this field | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 34 | $old =~ s/\b(\w)/\u$1/g; | |||||||||||||||||||||||||||||||||||||||||
| 190 | 34 | $standard_case{$field} = $old; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 74 | $field_name{$old} = $field; | |||||||||||||||||||||||||||||||||||||||||
| 193 | 74 | return $field; | |||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 41 | ▶ | sub _header_get { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_header_get: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | 41 | my ($self, $field, $skip_standardize) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 41 | ▶ | $field = _standardize_field_name($field) unless $skip_standardize || $field =~ /^:/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$skip_standardize or $field =~ /^:/
MC/DC100%2/2
$skip_standardize or $field =~ /^:/
$skip_standardize
$field =~ /^:/
Truth table100%3/3
A or B
A= $skip_standardizeB= $field =~ /^:/
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 41 | my $h = $self->{$field}; | |||||||||||||||||||||||||||||||||||||||||
| 202 | 41 | ▶ | return (ref($h) eq 'ARRAY') ? @$h : ( defined($h) ? ($h) : () ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 85 | ▶ | sub _header_set { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_header_set: called CC=7 SCAR=19.6
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 85 | my ($self, $field, $val) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 85 | ▶ | $field = _standardize_field_name($field) unless $field =~ /^:/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | 85 | my $h = $self->{$field}; | |||||||||||||||||||||||||||||||||||||||||
| 211 | 85 | ▶ | my @old = ref($h) eq 'ARRAY' ? @$h : ( defined($h) ? ($h) : () ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 85 | ▶ | if ( defined($val) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | 84 | ▶ | if (ref $val eq 'ARRAY' && scalar(@$val) == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $val eq "ARRAY" and scalar @$val == 1
MC/DC0%0/2
ref $val eq "ARRAY" and scalar @$val == 1
ref $val eq "ARRAY"
scalar @$val == 1
Truth table66%2/3
A and B
A= ref $val eq "ARRAY"B= scalar @$val == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $val = $val->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 84 | $self->{$field} = $val; | |||||||||||||||||||||||||||||||||||||||||
| 217 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | delete $self->{$field}; | |||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 85 | return @old; | |||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 7 | ▶ | sub _header_push { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_header_push: called CC=7 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | 7 | my ($self, $field, $val) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | 7 | ▶ | $field = _standardize_field_name($field) unless $field =~ /^:/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 7 | my $h = $self->{$field}; | |||||||||||||||||||||||||||||||||||||||||
| 229 | 7 | ▶ | if (ref($h) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 3 | my @old = @$h; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 3 | ▶ | push @$h, ref $val ne 'ARRAY' ? $val : @$val; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 3 | return @old; | |||||||||||||||||||||||||||||||||||||||||
| 233 | } elsif (defined $h) { | ||||||||||||||||||||||||||||||||||||||||||
| 234 | 4 | ▶ | $self->{$field} = [$h, ref $val ne 'ARRAY' ? $val : @$val ]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 4 | return ($h); | |||||||||||||||||||||||||||||||||||||||||
| 236 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | $self->{$field} = ref $val ne 'ARRAY' ? $val : @$val; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | return (); | |||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 24 | ▶ | sub _header { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_header: called CC=14 SCAR=27.0
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 24 | my ($self, $field, $val, $op) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 24 | ▶ | $field = _standardize_field_name($field) unless $field =~ /^:/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 24 | ▶ | $op ||= defined($val) ? $OP_SET : $OP_GET; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$op ||= defined $val ? $OP_SET : $OP_GET
MC/DC100%2/2
$op ||= defined $val ? $OP_SET : $OP_GET
$op
defined $val ? $OP_SET : $OP_GET
Truth table100%3/3
A ||= B
A= $opB= defined $val ? $OP_SET : $OP_GET
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 24 | my $h = $self->{$field}; | |||||||||||||||||||||||||||||||||||||||||
| 250 | 24 | ▶ | my @old = ref($h) eq 'ARRAY' ? @$h : ( defined($h) ? ($h) : () ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 24 | ▶ | unless ( $op == $OP_GET || ( $op == $OP_INIT && @old ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$op == $OP_GET or $op == $OP_INIT and @old
$op == $OP_INIT and @old
MC/DC100%3/3
$op == $OP_GET or $op == $OP_INIT and @old
$op == $OP_GET
$op == $OP_INIT
@old
Truth table100%4/4
A or B and C
A= $op == $OP_GETB= $op == $OP_INITC= @old
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 8 | ▶ | if ( defined($val) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 8 | ▶ | my @new = ( $op == $OP_PUSH ) ? @old : (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 8 | ▶ | if ( ref($val) ne 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 7 | push( @new, $val ); | |||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | push( @new, @$val ); | |||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 8 | ▶ | $self->{$field} = @new > 1 ? \@new : $new[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | elsif ( $op != $OP_PUSH ) { | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | delete $self->{$field}; | |||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||||||||||||
| 267 | 24 | @old; | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 45 | ▶ | sub _sorted_field_names { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sorted_field_names: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 45 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 272 | return [ sort { | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 45 | ▶ | ( $header_order{$a} || 999 ) <=> ( $header_order{$b} || 999 ) | ||||||||||||||||||||||||||||||||||||||||
|
Condition85%6/7
($header_order{$a} || 999) <=> ($header_order{$b} || 999) || $a cmp $b
$header_order{$a} || 999
$header_order{$b} || 999
MC/DC0%0/2
($header_order{$a} || 999) <=> ($header_order{$b} || 999) || $a cmp $b
$header_order{$a}
$a cmp $b
MC/DC100%1/1
$header_order{$b} || 999
$header_order{$b}
Truth table66%2/3
A || B
A= $header_order{$a}B= $a cmp $b
Truth table100%2/2
A
A= $header_order{$b}
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | || $a cmp $b | ||||||||||||||||||||||||||||||||||||||||||
| 275 | } keys %$self ]; | ||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | 8 | ▶ | sub header_field_names { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header_field_names: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 280 | 8 | ▶ | return map $standard_case{$_} || $_, @{ $self->_sorted_field_names } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$HTTP::Headers::Fast::standard_case{$_} || $_
MC/DC0%0/2
$HTTP::Headers::Fast::standard_case{$_} || $_
$HTTP::Headers::Fast::standard_case{$_}
$_
Truth table66%2/3
A || B
A= $HTTP::Headers::Fast::standard_case{$_}B= $_
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | if wantarray; | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 2 | return keys %$self; | |||||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||
| 285 | 4 | ▶ | sub scan { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scan: called CC=7 SCAR=20.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | 4 | my ( $self, $sub ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 287 | 4 | for my $key (@{ $self->_sorted_field_names }) { | |||||||||||||||||||||||||||||||||||||||||
| 288 | 12 | ▶ | next if substr($key, 0, 1) eq '_'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | 12 | my $vals = $self->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 290 | 12 | ▶ | if ( ref($vals) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 3 | for my $val (@$vals) { | |||||||||||||||||||||||||||||||||||||||||
| 292 | 7 | ▶ | $sub->( $standard_case{$key} || $key, $val ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$HTTP::Headers::Fast::standard_case{$key} || $key
MC/DC0%0/2
$HTTP::Headers::Fast::standard_case{$key} || $key
$HTTP::Headers::Fast::standard_case{$key}
$key
Truth table33%1/3
A || B
A= $HTTP::Headers::Fast::standard_case{$key}B= $key
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||
| 295 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 9 | ▶ | $sub->( $standard_case{$key} || $key, $vals ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$HTTP::Headers::Fast::standard_case{$key} || $key
MC/DC0%0/2
$HTTP::Headers::Fast::standard_case{$key} || $key
$HTTP::Headers::Fast::standard_case{$key}
$key
Truth table33%1/3
A || B
A= $HTTP::Headers::Fast::standard_case{$key}B= $key
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | 10 | ▶ | sub _process_newline { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_process_newline: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | 10 | local $_ = shift; | |||||||||||||||||||||||||||||||||||||||||
| 303 | 10 | my $endl = shift; | |||||||||||||||||||||||||||||||||||||||||
| 304 | # must handle header values with embedded newlines with care | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 10 | s/\s+$//; # trailing newlines and space must go | |||||||||||||||||||||||||||||||||||||||||
| 306 | 10 | s/\n(\x0d?\n)+/\n/g; # no empty lines | |||||||||||||||||||||||||||||||||||||||||
| 307 | 10 | s/\n([^\040\t])/\n $1/g; # intial space for continuation | |||||||||||||||||||||||||||||||||||||||||
| 308 | 10 | s/\n/$endl/g; # substitute with requested line ending | |||||||||||||||||||||||||||||||||||||||||
| 309 | 10 | $_; | |||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | 28 | ▶ | sub _as_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_as_string: called CC=9 SCAR=22.3
| |||||||||||||||||||||||||||||||||||||||||||
| 313 | 28 | my ($self, $endl, $fieldnames) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | 28 | my @result; | |||||||||||||||||||||||||||||||||||||||||
| 316 | 28 | for my $key ( @$fieldnames ) { | |||||||||||||||||||||||||||||||||||||||||
| 317 | 114 | ▶ | next if index($key, '_') == 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 318 | 114 | my $vals = $self->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 319 | 114 | ▶ | if ( ref($vals) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 7 | for my $val (@$vals) { | |||||||||||||||||||||||||||||||||||||||||
| 321 | 16 | ▶ | my $field = $standard_case{$key} || $key; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$HTTP::Headers::Fast::standard_case{$key} || $key
MC/DC0%0/2
$HTTP::Headers::Fast::standard_case{$key} || $key
$HTTP::Headers::Fast::standard_case{$key}
$key
Truth table66%2/3
A || B
A= $HTTP::Headers::Fast::standard_case{$key}B= $key
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 16 | $field =~ s/^://; | |||||||||||||||||||||||||||||||||||||||||
| 323 | 16 | ▶ | if ( index($val, "\n") >= 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | $val = _process_newline($val, $endl); | |||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 16 | push @result, $field . ': ' . $val; | |||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 329 | 107 | ▶ | my $field = $standard_case{$key} || $key; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$HTTP::Headers::Fast::standard_case{$key} || $key
MC/DC0%0/2
$HTTP::Headers::Fast::standard_case{$key} || $key
$HTTP::Headers::Fast::standard_case{$key}
$key
Truth table66%2/3
A || B
A= $HTTP::Headers::Fast::standard_case{$key}B= $key
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 107 | $field =~ s/^://; | |||||||||||||||||||||||||||||||||||||||||
| 331 | 107 | ▶ | if ( index($vals, "\n") >= 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | 10 | $vals = _process_newline($vals, $endl); | |||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | 107 | push @result, $field . ': ' . $vals; | |||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | 28 | join( $endl, @result, '' ); | |||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | 27 | ▶ | sub as_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | 27 | my ( $self, $endl ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 343 | 27 | ▶ | $endl = "\n" unless defined $endl; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 27 | $self->_as_string($endl, $self->_sorted_field_names); | |||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 1 | ▶ | sub as_string_without_sort { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string_without_sort: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 1 | my ( $self, $endl ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 349 | 1 | ▶ | $endl = "\n" unless defined $endl; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 1 | $self->_as_string($endl, [keys(%$self)]); | |||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | 12 | ▶ | sub _psgi_flatten { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_psgi_flatten: called CC=7 SCAR=20.2
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | 12 | my ($self, $keys) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 356 | 12 | my @headers; | |||||||||||||||||||||||||||||||||||||||||
| 357 | 12 | for my $key ( @{$keys} ) { | |||||||||||||||||||||||||||||||||||||||||
| 358 | 19 | ▶ | next if substr($key, 0, 1) eq '_'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 19 | my $vals = $self->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 360 | 19 | ▶ | if ( ref($vals) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 3 | for my $val (@$vals) { | |||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | $val =~ s/\015\012[\040|\011]+/chr(32)/ge; # replace LWS with a single SP | |||||||||||||||||||||||||||||||||||||||||
| 363 | 8 | $val =~ s/\015|\012//g; # remove CR and LF since the char is invalid here | |||||||||||||||||||||||||||||||||||||||||
| 364 | 8 | ▶ | push @headers, $standard_case{$key} || $key, $val; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$HTTP::Headers::Fast::standard_case{$key} || $key
MC/DC0%0/2
$HTTP::Headers::Fast::standard_case{$key} || $key
$HTTP::Headers::Fast::standard_case{$key}
$key
Truth table33%1/3
A || B
A= $HTTP::Headers::Fast::standard_case{$key}B= $key
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||
| 367 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 368 | 16 | $vals =~ s/\015\012[\040|\011]+/chr(32)/ge; # replace LWS with a single SP | |||||||||||||||||||||||||||||||||||||||||
| 369 | 16 | $vals =~ s/\015|\012//g; # remove CR and LF since the char is invalid here | |||||||||||||||||||||||||||||||||||||||||
| 370 | 16 | ▶ | push @headers, $standard_case{$key} || $key, $vals; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$HTTP::Headers::Fast::standard_case{$key} || $key
MC/DC0%0/2
$HTTP::Headers::Fast::standard_case{$key} || $key
$HTTP::Headers::Fast::standard_case{$key}
$key
Truth table33%1/3
A || B
A= $HTTP::Headers::Fast::standard_case{$key}B= $key
| |||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 373 | 12 | return \@headers; | |||||||||||||||||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | 8 | ▶ | sub psgi_flatten { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
psgi_flatten: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 377 | 8 | $_[0]->_psgi_flatten($_[0]->_sorted_field_names); | |||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||
| 381 | 4 | ▶ | sub psgi_flatten_without_sort { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
psgi_flatten_without_sort: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | 4 | $_[0]->_psgi_flatten([keys %{$_[0]}]); | |||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | { | ||||||||||||||||||||||||||||||||||||||||||
| 386 | 8 | my $storable_required; | |||||||||||||||||||||||||||||||||||||||||
| 387 | 12 | ▶ | sub clone { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | 12 | ▶ | unless ($storable_required) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | 1 | require Storable; | |||||||||||||||||||||||||||||||||||||||||
| 390 | 1 | $storable_required++; | |||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 12 | goto &Storable::dclone; | |||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | 8 | ▶ | sub _date_header { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_date_header: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 397 | 16 | require HTTP::Date; | |||||||||||||||||||||||||||||||||||||||||
| 398 | 16 | my ( $self, $header, $time ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 399 | 16 | my $old; | |||||||||||||||||||||||||||||||||||||||||
| 400 | 16 | ▶ | if ( defined $time ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | 5 | ($old) = $self->_header_set( $header, HTTP::Date::time2str($time) ); | |||||||||||||||||||||||||||||||||||||||||
| 402 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 403 | 11 | ($old) = $self->_header_get($header, 1); | |||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | 16 | ▶ | $old =~ s/;.*// if defined($old); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | 16 | HTTP::Date::str2time($old); | |||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | 3 | ▶ | sub date { shift->_date_header( 'date', @_ ); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
date: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 410 | 3 | ▶ | sub expires { shift->_date_header( 'expires', @_ ); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
expires: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | 4 | ▶ | sub if_modified_since { shift->_date_header( 'if-modified-since', @_ ); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
if_modified_since: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 412 | 3 | ▶ | sub if_unmodified_since { shift->_date_header( 'if-unmodified-since', @_ ); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
if_unmodified_since: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | 3 | ▶ | sub last_modified { shift->_date_header( 'last-modified', @_ ); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
last_modified: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | # This is used as a private LWP extension. The Client-Date header is | ||||||||||||||||||||||||||||||||||||||||||
| 416 | # added as a timestamp to a response when it has been received. | ||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | sub client_date { shift->_date_header( 'client-date', @_ ); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
client_date: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | # The retry_after field is dual format (can also be a expressed as | ||||||||||||||||||||||||||||||||||||||||||
| 420 | # number of seconds from now), so we don't provide an easy way to | ||||||||||||||||||||||||||||||||||||||||||
| 421 | # access it until we have know how both these interfaces can be | ||||||||||||||||||||||||||||||||||||||||||
| 422 | # addressed. One possibility is to return a negative value for | ||||||||||||||||||||||||||||||||||||||||||
| 423 | # relative seconds and a positive value for epoch based time values. | ||||||||||||||||||||||||||||||||||||||||||
| 424 | #sub retry_after { shift->_date_header('Retry-After', @_); } | ||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||
| 426 | 29 | ▶ | sub content_type { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_type: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 427 | 29 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 428 | 29 | my $ct = $self->{'content-type'}; | |||||||||||||||||||||||||||||||||||||||||
| 429 | 29 | ▶ | $self->{'content-type'} = shift if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | 29 | ▶ | $ct = $ct->[0] if ref($ct) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 431 | 29 | ▶ | return '' unless defined($ct) && length($ct); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $ct and length $ct
MC/DC50%1/2
defined $ct and length $ct
defined $ct
length $ct
Truth table66%2/3
A and B
A= defined $ctB= length $ct
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | 24 | my @ct = split( /;\s*/, $ct, 2 ); | |||||||||||||||||||||||||||||||||||||||||
| 433 | 24 | for ( $ct[0] ) { | |||||||||||||||||||||||||||||||||||||||||
| 434 | 24 | s/\s+//g; | |||||||||||||||||||||||||||||||||||||||||
| 435 | 24 | $_ = lc($_); | |||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||
| 437 | 24 | ▶ | wantarray ? @ct : $ct[0]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | 2 | ▶ | sub content_type_charset { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_type_charset: called CC=9 SCAR=22.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 442 | 2 | my $h = $self->{'content-type'}; | |||||||||||||||||||||||||||||||||||||||||
| 443 | 2 | ▶ | $h = $h->[0] if ref($h); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 444 | 2 | ▶ | $h = "" unless defined $h; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 445 | 2 | my @v = _split_header_words($h); | |||||||||||||||||||||||||||||||||||||||||
| 446 | 2 | ▶ | if (@v) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | 1 | my($ct, undef, %ct_param) = @{$v[0]}; | |||||||||||||||||||||||||||||||||||||||||
| 448 | 1 | my $charset = $ct_param{charset}; | |||||||||||||||||||||||||||||||||||||||||
| 449 | 1 | ▶ | if ($ct) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 450 | 1 | $ct = lc($ct); | |||||||||||||||||||||||||||||||||||||||||
| 451 | 1 | $ct =~ s/\s+//; | |||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||
| 453 | 1 | ▶ | if ($charset) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 454 | 1 | $charset = uc($charset); | |||||||||||||||||||||||||||||||||||||||||
| 455 | 1 | $charset =~ s/^\s+//; $charset =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||
| 456 | 1 | ▶ | undef($charset) if $charset eq ""; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||
| 458 | 1 | ▶ | return $ct, $charset if wantarray; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 459 | 1 | return $charset; | |||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||
| 461 | 1 | ▶ | return undef, undef if wantarray; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 462 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | sub _split_header_words | ||||||||||||||||||||||||||||||||||||||||||
| 466 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_split_header_words: called CC=13 SCAR=28.5
| |||||||||||||||||||||||||||||||||||||||||||
| 467 | 2 | my(@val) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 468 | 2 | my @res; | |||||||||||||||||||||||||||||||||||||||||
| 469 | 2 | for (@val) { | |||||||||||||||||||||||||||||||||||||||||
| 470 | 2 | my @cur; | |||||||||||||||||||||||||||||||||||||||||
| 471 | 2 | ▶ | while (length) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | 3 | ▶ | if (s/^\s*(=*[^\s=;,]+)//) { # 'token' or parameter 'attribute' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 473 | 2 | push(@cur, $1); | |||||||||||||||||||||||||||||||||||||||||
| 474 | # a quoted value | ||||||||||||||||||||||||||||||||||||||||||
| 475 | 2 | ▶ | if (s/^\s*=\s*\"([^\"\\]*(?:\\.[^\"\\]*)*)\"//) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 476 | 1 | my $val = $1; | |||||||||||||||||||||||||||||||||||||||||
| 477 | 1 | $val =~ s/\\(.)/$1/g; | |||||||||||||||||||||||||||||||||||||||||
| 478 | 1 | push(@cur, $val); | |||||||||||||||||||||||||||||||||||||||||
| 479 | # some unquoted value | ||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||
| 481 | elsif (s/^\s*=\s*([^;,\s]*)//) { | ||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | my $val = $1; | |||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | $val =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | push(@cur, $val); | |||||||||||||||||||||||||||||||||||||||||
| 485 | # no value, a lone token | ||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||
| 487 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 488 | 1 | push(@cur, undef); | |||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||
| 491 | elsif (s/^\s*,//) { | ||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | push(@res, [@cur]) if @cur; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | @cur = (); | |||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||
| 495 | ▶ | elsif (s/^\s*;// || s/^\s+//) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
s/^\s*;// or s/^\s+//
MC/DC0%0/2
s/^\s*;// or s/^\s+//
s/^\s*;//
s/^\s+//
Truth table33%1/3
A or B
A= s/^\s*;//B= s/^\s+//
| |||||||||||||||||||||||||||||||||||||||||||
| 496 | # continue | ||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||
| 498 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | die "This should not happen: '$_'"; | |||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||
| 502 | 2 | ▶ | push(@res, \@cur) if @cur; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||
| 505 | 2 | for my $arr (@res) { | |||||||||||||||||||||||||||||||||||||||||
| 506 | 1 | ▶ | for (my $i = @$arr - 2; $i >= 0; $i -= 2) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 507 | 2 | $arr->[$i] = lc($arr->[$i]); | |||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||
| 510 | 2 | return @res; | |||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||
| 513 | 3 | ▶ | sub content_is_text { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_is_text: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 514 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 515 | 3 | return $self->content_type =~ m,^text/,; | |||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||
| 518 | 3 | ▶ | sub content_is_html { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_is_html: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 519 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 520 | 3 | ▶ | return $self->content_type eq 'text/html' || $self->content_is_xhtml; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$self->content_type eq 'text/html' || $self->content_is_xhtml
MC/DC100%2/2
$self->content_type eq 'text/html' || $self->content_is_xhtml
$self->content_type eq 'text/html'
$self->content_is_xhtml
Truth table100%3/3
A || B
A= $self->content_type eq 'text/html'B= $self->content_is_xhtml
| |||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||
| 523 | 5 | ▶ | sub content_is_xhtml { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_is_xhtml: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | 5 | my $ct = shift->content_type; | |||||||||||||||||||||||||||||||||||||||||
| 525 | 5 | ▶ | return $ct eq "application/xhtml+xml" | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$ct eq 'application/xhtml+xml' || $ct eq 'application/vnd.wap.xhtml+xml'
MC/DC50%1/2
$ct eq 'application/xhtml+xml' || $ct eq 'application/vnd.wap.xhtml+xml'
$ct eq 'application/xhtml+xml'
$ct eq 'application/vnd.wap.xhtml+xml'
Truth table66%2/3
A || B
A= $ct eq 'application/xhtml+xml'B= $ct eq 'application/vnd.wap.xhtml+xml'
| |||||||||||||||||||||||||||||||||||||||||||
| 526 | || $ct eq "application/vnd.wap.xhtml+xml"; | ||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||
| 529 | 3 | ▶ | sub content_is_xml { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_is_xml: called CC=4 SCAR=14.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 530 | 3 | my $ct = shift->content_type; | |||||||||||||||||||||||||||||||||||||||||
| 531 | 3 | ▶ | return 1 if $ct eq "text/xml"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 532 | 3 | ▶ | return 1 if $ct eq "application/xml"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | 3 | ▶ | return 1 if $ct =~ /\+xml$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 534 | 2 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||
| 537 | 8 | ▶ | sub referer { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
referer: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 538 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 539 | 8 | ▶ | if ( @_ && $_[0] =~ /#/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ and $_[0] =~ /#/
MC/DC100%2/2
@_ and $_[0] =~ /#/
@_
$_[0] =~ /#/
Truth table100%3/3
A and B
A= @_B= $_[0] =~ /#/
| |||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | # Strip fragment per RFC 2616, section 14.36. | ||||||||||||||||||||||||||||||||||||||||||
| 542 | 2 | my $uri = shift; | |||||||||||||||||||||||||||||||||||||||||
| 543 | 2 | ▶ | if ( ref($uri) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 544 | 1 | $uri = $uri->clone; | |||||||||||||||||||||||||||||||||||||||||
| 545 | 1 | $uri->fragment(undef); | |||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||
| 547 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 548 | 1 | $uri =~ s/\#.*//; | |||||||||||||||||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||||||||||||||||
| 550 | 2 | unshift @_, $uri; | |||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||
| 552 | 8 | ( $self->_header( 'Referer', @_ ) )[0]; | |||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||
| 554 | 8 | *referrer = \&referer; # on tchrist's request | |||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||
| 556 | 8 | for my $key (qw/content-length content-language content-encoding title user-agent server from warnings www-authenticate authorization proxy-authenticate proxy-authorization/) { | |||||||||||||||||||||||||||||||||||||||||
| 557 | 8 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 558 | 96 | (my $meth = $key) =~ s/-/_/g; | |||||||||||||||||||||||||||||||||||||||||
| 559 | 96 | ▶ | *{$meth} = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 560 | 24 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 561 | 24 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 562 | 10 | ( $self->_header_set( $key, @_ ) )[0] | |||||||||||||||||||||||||||||||||||||||||
| 563 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 564 | 14 | my $h = $self->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 565 | 14 | ▶ | (ref($h) eq 'ARRAY') ? $h->[0] : $h; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||
| 567 | 96 | }; | |||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||
| 570 | 7 | ▶ | sub authorization_basic { shift->_basic_auth( "Authorization", @_ ) } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
authorization_basic: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 571 | 2 | ▶ | sub proxy_authorization_basic { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
proxy_authorization_basic: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 572 | 2 | shift->_basic_auth( "Proxy-Authorization", @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | 9 | ▶ | sub _basic_auth { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_basic_auth: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||
| 576 | 9 | require MIME::Base64; | |||||||||||||||||||||||||||||||||||||||||
| 577 | 9 | my ( $self, $h, $user, $passwd ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 578 | 9 | my ($old) = $self->_header($h); | |||||||||||||||||||||||||||||||||||||||||
| 579 | 9 | ▶ | if ( defined $user ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 580 | 4 | ▶ | Carp::croak("Basic authorization user name can't contain ':'") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 581 | if $user =~ /:/; | ||||||||||||||||||||||||||||||||||||||||||
| 582 | 3 | ▶ | $passwd = '' unless defined $passwd; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 583 | 3 | $self->_header( | |||||||||||||||||||||||||||||||||||||||||
| 584 | $h => 'Basic ' . MIME::Base64::encode( "$user:$passwd", '' ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||
| 586 | 8 | ▶ | if ( defined $old && $old =~ s/^\s*Basic\s+// ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $old and $old =~ s/^\s*Basic\s+//
MC/DC50%1/2
defined $old and $old =~ s/^\s*Basic\s+//
defined $old
$old =~ s/^\s*Basic\s+//
Truth table66%2/3
A and B
A= defined $oldB= $old =~ s/^\s*Basic\s+//
| |||||||||||||||||||||||||||||||||||||||||||
| 587 | 5 | my $val = MIME::Base64::decode($old); | |||||||||||||||||||||||||||||||||||||||||
| 588 | 5 | ▶ | return $val unless wantarray; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 589 | 3 | return split( /:/, $val, 2 ); | |||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||
| 591 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||
| 594 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 595 | __END__ | ||||||||||||||||||||||||||||||||||||||||||