| 1 | package HTTP::XSHeaders; | ||||||||||||||||||||||||||||
| 2 | 13 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 13 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 13 | ▶ | use XSLoader; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 13 | our $VERSION = '1.000100'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 13 | eval { | |||||||||||||||||||||||||||
| 9 | 13 | require HTTP::Headers::Fast; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 13 | ▶ | no warnings qw<redefine prototype>; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | # HTTP::Headers::Fast | ||||||||||||||||||||||||||||
| 13 | 0 | *HTTP::Headers::Fast::new = *HTTP::XSHeaders::new; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 0 | my %fast_orig; | |||||||||||||||||||||||||||
| 16 | 0 | my @fast_methods = qw( | |||||||||||||||||||||||||||
| 17 | clone header _header clear push_header init_header remove_header | ||||||||||||||||||||||||||||
| 18 | remove_content_headers as_string as_string_without_sort header_field_names | ||||||||||||||||||||||||||||
| 19 | psgi_flatten psgi_flatten_without_sort scan | ||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | for my $meth (@fast_methods) { | |||||||||||||||||||||||||||
| 23 | 0 | $fast_orig{$meth} = HTTP::Headers::Fast->can($meth); | |||||||||||||||||||||||||||
| 24 | 13 | ▶ | no strict 'refs'; ## no critic | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 0 | ▶ | *{ "HTTP::Headers::Fast::$meth" } = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 26 | HTTP::XSHeaders::_dispatch_xs_or_orig( | ||||||||||||||||||||||||||||
| 27 | shift, | ||||||||||||||||||||||||||||
| 28 | 0 | \&{ "HTTP::XSHeaders::$meth" }, | |||||||||||||||||||||||||||
| 29 | 0 | $fast_orig{$meth}, | |||||||||||||||||||||||||||
| 30 | @_, | ||||||||||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||||||||||
| 32 | 0 | }; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | # Implemented in Pure-Perl | ||||||||||||||||||||||||||||
| 36 | # (candidates to move to XS) | ||||||||||||||||||||||||||||
| 37 | 0 | *HTTP::Headers::Fast::_date_header = *HTTP::XSHeaders::_date_header; | |||||||||||||||||||||||||||
| 38 | 0 | *HTTP::Headers::Fast::content_type = *HTTP::XSHeaders::content_type; | |||||||||||||||||||||||||||
| 39 | 0 | *HTTP::Headers::Fast::content_type_charset = *HTTP::XSHeaders::content_type_charset; | |||||||||||||||||||||||||||
| 40 | 0 | *HTTP::Headers::Fast::referer = *HTTP::XSHeaders::referer; | |||||||||||||||||||||||||||
| 41 | 0 | *HTTP::Headers::Fast::referrer = *HTTP::XSHeaders::referer; | |||||||||||||||||||||||||||
| 42 | 0 | *HTTP::Headers::Fast::_basic_auth = *HTTP::XSHeaders::_basic_auth; | |||||||||||||||||||||||||||
| 43 | }; | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 13 | eval { | |||||||||||||||||||||||||||
| 46 | 13 | require HTTP::Headers; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 13 | ▶ | no warnings qw<redefine prototype>; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 49 | # HTTP::Headers | ||||||||||||||||||||||||||||
| 50 | 13 | *HTTP::Headers::new = *HTTP::XSHeaders::new; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 13 | my %headers_orig; | |||||||||||||||||||||||||||
| 53 | 13 | my @headers_methods = qw( | |||||||||||||||||||||||||||
| 54 | clone header _header clear push_header init_header remove_header | ||||||||||||||||||||||||||||
| 55 | remove_content_headers as_string header_field_names psgi_flatten | ||||||||||||||||||||||||||||
| 56 | psgi_flatten_without_sort scan | ||||||||||||||||||||||||||||
| 57 | ); | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 13 | for my $meth (@headers_methods) { | |||||||||||||||||||||||||||
| 60 | 169 | $headers_orig{$meth} = HTTP::Headers->can($meth); | |||||||||||||||||||||||||||
| 61 | 13 | ▶ | no strict 'refs'; ## no critic | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 62 | 169 | ▶ | *{ "HTTP::Headers::$meth" } = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 63 | HTTP::XSHeaders::_dispatch_xs_or_orig( | ||||||||||||||||||||||||||||
| 64 | shift, | ||||||||||||||||||||||||||||
| 65 | 4 | \&{ "HTTP::XSHeaders::$meth" }, | |||||||||||||||||||||||||||
| 66 | 4 | $headers_orig{$meth}, | |||||||||||||||||||||||||||
| 67 | @_, | ||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||
| 69 | 169 | }; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | # Implemented in Pure-Perl | ||||||||||||||||||||||||||||
| 73 | 13 | *HTTP::Headers::_date_header = *HTTP::XSHeaders::_date_header; | |||||||||||||||||||||||||||
| 74 | 13 | *HTTP::Headers::content_type = *HTTP::XSHeaders::content_type; | |||||||||||||||||||||||||||
| 75 | 13 | *HTTP::Headers::content_type_charset = *HTTP::XSHeaders::content_type_charset; | |||||||||||||||||||||||||||
| 76 | 13 | *HTTP::Headers::referer = *HTTP::XSHeaders::referer; | |||||||||||||||||||||||||||
| 77 | 13 | *HTTP::Headers::referrer = *HTTP::XSHeaders::referer; | |||||||||||||||||||||||||||
| 78 | 13 | *HTTP::Headers::_basic_auth = *HTTP::XSHeaders::_basic_auth; | |||||||||||||||||||||||||||
| 79 | }; | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 13 | XSLoader::load( 'HTTP::XSHeaders', $VERSION ); | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | { | ||||||||||||||||||||||||||||
| 84 | 13 | ▶ | no warnings qw<redefine once>; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 85 | 13 | for my $key (qw/content-length content-language content-encoding title user-agent server from warnings www-authenticate authorization proxy-authenticate proxy-authorization/) { | |||||||||||||||||||||||||||
| 86 | 156 | (my $meth = $key) =~ s/-/_/g; | |||||||||||||||||||||||||||
| 87 | 13 | ▶ | no strict 'refs'; ## no critic | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 88 | 24 | ▶ | *{$meth} = sub { (shift->header($key, @_))[0] }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 156 | ▶ | *{ "HTTP::Headers::$meth" } = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 91 | 0 | (shift->header($key, @_))[0]; | |||||||||||||||||||||||||||
| 92 | 156 | }; | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 156 | ▶ | *{ "HTTP::Headers::Fast::$meth" } = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 95 | 0 | (shift->header($key, @_))[0]; | |||||||||||||||||||||||||||
| 96 | 156 | }; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 13 | ▶ | use 5.00800; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 101 | 13 | ▶ | use Carp (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | 4 | ▶ | sub _dispatch_xs_or_orig { | ||||||||||||||||||||||||||
|
Subroutine
_dispatch_xs_or_orig: called CC=3 SCAR=13.5
| |||||||||||||||||||||||||||||
| 104 | 4 | my ( $self, $xs, $orig, @args ) = @_; | |||||||||||||||||||||||||||
| 105 | 4 | ▶ | if ( HTTP::XSHeaders::_is_xsheaders($self) || !$orig ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
_is_xsheaders($self) or not $orig
MC/DC0%0/2
_is_xsheaders($self) or not $orig
_is_xsheaders($self)
not $orig
Truth table33%1/3
A or not(B)
A= _is_xsheaders($self)B= not $orig
| |||||||||||||||||||||||||||||
| 106 | 0 | @_ = ( $self, @args ); | |||||||||||||||||||||||||||
| 107 | 0 | goto &$xs; | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | 4 | @_ = ( $self, @args ); | |||||||||||||||||||||||||||
| 110 | 4 | goto &$orig; | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 16 | ▶ | sub _date_header { | ||||||||||||||||||||||||||
|
Subroutine
_date_header: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 114 | 16 | require HTTP::Date; | |||||||||||||||||||||||||||
| 115 | 16 | my ( $self, $header, $time ) = @_; | |||||||||||||||||||||||||||
| 116 | 16 | my $old; | |||||||||||||||||||||||||||
| 117 | 16 | ▶ | if ( defined $time ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | 5 | ($old) = $self->header($header, HTTP::Date::time2str($time)); | |||||||||||||||||||||||||||
| 119 | } else { | ||||||||||||||||||||||||||||
| 120 | 11 | ($old) = $self->header($header); | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | 16 | ▶ | $old =~ s/;.*// if defined($old); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | 16 | HTTP::Date::str2time($old); | |||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | 20 | ▶ | sub content_type { | ||||||||||||||||||||||||||
|
Subroutine
content_type: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||
| 127 | 20 | my $self = shift; | |||||||||||||||||||||||||||
| 128 | 20 | my $ct = $self->header('content-type'); | |||||||||||||||||||||||||||
| 129 | 20 | ▶ | $self->header('content-type', shift) if @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | 20 | ▶ | $ct = $ct->[0] if ref($ct) eq 'ARRAY'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | 20 | ▶ | 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
| |||||||||||||||||||||||||||||
| 132 | 16 | my @ct = split( /;\s*/, $ct, 2 ); | |||||||||||||||||||||||||||
| 133 | 16 | for ( $ct[0] ) { | |||||||||||||||||||||||||||
| 134 | 16 | s/\s+//g; | |||||||||||||||||||||||||||
| 135 | 16 | $_ = lc($_); | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | 16 | ▶ | wantarray ? @ct : $ct[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | # This is copied here because it is not a method | ||||||||||||||||||||||||||||
| 141 | sub _split_header_words | ||||||||||||||||||||||||||||
| 142 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_split_header_words: called CC=13 SCAR=28.5
| |||||||||||||||||||||||||||||
| 143 | 2 | my(@val) = @_; | |||||||||||||||||||||||||||
| 144 | 2 | my @res; | |||||||||||||||||||||||||||
| 145 | 2 | for (@val) { | |||||||||||||||||||||||||||
| 146 | 2 | my @cur; | |||||||||||||||||||||||||||
| 147 | 2 | ▶ | while (length) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | 3 | ▶ | if (s/^\s*(=*[^\s=;,]+)//) { # 'token' or parameter 'attribute' | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 149 | 2 | push(@cur, $1); | |||||||||||||||||||||||||||
| 150 | # a quoted value | ||||||||||||||||||||||||||||
| 151 | 2 | ▶ | if (s/^\s*=\s*\"([^\"\\]*(?:\\.[^\"\\]*)*)\"//) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 152 | 1 | my $val = $1; | |||||||||||||||||||||||||||
| 153 | 1 | $val =~ s/\\(.)/$1/g; | |||||||||||||||||||||||||||
| 154 | 1 | push(@cur, $val); | |||||||||||||||||||||||||||
| 155 | # some unquoted value | ||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | elsif (s/^\s*=\s*([^;,\s]*)//) { | ||||||||||||||||||||||||||||
| 158 | 0 | my $val = $1; | |||||||||||||||||||||||||||
| 159 | 0 | $val =~ s/\s+$//; | |||||||||||||||||||||||||||
| 160 | 0 | push(@cur, $val); | |||||||||||||||||||||||||||
| 161 | # no value, a lone token | ||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | else { | ||||||||||||||||||||||||||||
| 164 | 1 | push(@cur, undef); | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||
| 167 | elsif (s/^\s*,//) { | ||||||||||||||||||||||||||||
| 168 | 0 | ▶ | push(@res, [@cur]) if @cur; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | 0 | @cur = (); | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | ▶ | 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+//
| |||||||||||||||||||||||||||||
| 172 | # continue | ||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | else { | ||||||||||||||||||||||||||||
| 175 | 0 | die "This should not happen: '$_'"; | |||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | 2 | ▶ | push(@res, \@cur) if @cur; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 2 | for my $arr (@res) { | |||||||||||||||||||||||||||
| 182 | 1 | ▶ | for (my $i = @$arr - 2; $i >= 0; $i -= 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | 2 | $arr->[$i] = lc($arr->[$i]); | |||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | 2 | return @res; | |||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 2 | ▶ | sub content_type_charset { | ||||||||||||||||||||||||||
|
Subroutine
content_type_charset: called CC=9 SCAR=22.3
Pod
documented
| |||||||||||||||||||||||||||||
| 190 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 191 | 2 | my $h = $self->header('content-type'); | |||||||||||||||||||||||||||
| 192 | 2 | ▶ | $h = $h->[0] if ref($h); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | 2 | ▶ | $h = "" unless defined $h; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 194 | 2 | my @v = _split_header_words($h); | |||||||||||||||||||||||||||
| 195 | 2 | ▶ | if (@v) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 196 | 1 | my($ct, undef, %ct_param) = @{$v[0]}; | |||||||||||||||||||||||||||
| 197 | 1 | my $charset = $ct_param{charset}; | |||||||||||||||||||||||||||
| 198 | 1 | ▶ | if ($ct) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 199 | 1 | $ct = lc($ct); | |||||||||||||||||||||||||||
| 200 | 1 | $ct =~ s/\s+//; | |||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||
| 202 | 1 | ▶ | if ($charset) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 203 | 1 | $charset = uc($charset); | |||||||||||||||||||||||||||
| 204 | 1 | $charset =~ s/^\s+//; $charset =~ s/\s+\z//; | |||||||||||||||||||||||||||
| 205 | 1 | ▶ | undef($charset) if $charset eq ""; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | 1 | ▶ | return $ct, $charset if wantarray; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 208 | 1 | return $charset; | |||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | 1 | ▶ | return undef, undef if wantarray; ## no critic | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 211 | 1 | return undef; ## no critic | |||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 8 | ▶ | sub referer { | ||||||||||||||||||||||||||
|
Subroutine
referer: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 215 | 8 | my $self = shift; | |||||||||||||||||||||||||||
| 216 | 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] =~ /#/
| |||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | # Strip fragment per RFC 2616, section 14.36. | ||||||||||||||||||||||||||||
| 219 | 2 | my $uri = shift; | |||||||||||||||||||||||||||
| 220 | 2 | ▶ | if ( ref($uri) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | 1 | require URI; | |||||||||||||||||||||||||||
| 222 | 1 | $uri = $uri->clone; | |||||||||||||||||||||||||||
| 223 | 1 | $uri->fragment(undef); | |||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | else { | ||||||||||||||||||||||||||||
| 226 | 1 | $uri =~ s/\#.*//; | |||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||
| 228 | 2 | unshift @_, $uri; | |||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | 8 | ( $self->header( 'Referer', @_ ) )[0]; | |||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 13 | *referrer = \&referer; | |||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 7 | ▶ | sub authorization_basic { shift->_basic_auth( "Authorization", @_ ) } | ||||||||||||||||||||||||||
|
Subroutine
authorization_basic: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 236 | 2 | ▶ | sub proxy_authorization_basic { | ||||||||||||||||||||||||||
|
Subroutine
proxy_authorization_basic: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 237 | 2 | shift->_basic_auth( "Proxy-Authorization", @_ ); | |||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 9 | ▶ | sub _basic_auth { | ||||||||||||||||||||||||||
|
Subroutine
_basic_auth: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||
| 241 | 9 | require MIME::Base64; | |||||||||||||||||||||||||||
| 242 | 9 | my ( $self, $h, $user, $passwd ) = @_; | |||||||||||||||||||||||||||
| 243 | 9 | my ($old) = $self->header($h); | |||||||||||||||||||||||||||
| 244 | 9 | ▶ | if ( defined $user ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 245 | 4 | ▶ | Carp::croak("Basic authorization user name can't contain ':'") | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 246 | if $user =~ /:/; | ||||||||||||||||||||||||||||
| 247 | 3 | ▶ | $passwd = '' unless defined $passwd; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | 3 | $self->header( | |||||||||||||||||||||||||||
| 249 | $h => 'Basic ' . MIME::Base64::encode( "$user:$passwd", '' ) ); | ||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||
| 251 | 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+//
| |||||||||||||||||||||||||||||
| 252 | 5 | my $val = MIME::Base64::decode($old); | |||||||||||||||||||||||||||
| 253 | 5 | ▶ | return $val unless wantarray; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 254 | 3 | return split( /:/, $val, 2 ); | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | 3 | return; | |||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||
| 259 | 3 | ▶ | sub date { shift->_date_header( 'date', @_ ); } | ||||||||||||||||||||||||||
|
Subroutine
date: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 260 | 3 | ▶ | sub expires { shift->_date_header( 'expires', @_ ); } | ||||||||||||||||||||||||||
|
Subroutine
expires: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 261 | 4 | ▶ | sub if_modified_since { shift->_date_header( 'if-modified-since', @_ ); } | ||||||||||||||||||||||||||
|
Subroutine
if_modified_since: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 262 | 3 | ▶ | sub if_unmodified_since { shift->_date_header( 'if-unmodified-since', @_ ); } | ||||||||||||||||||||||||||
|
Subroutine
if_unmodified_since: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 263 | 3 | ▶ | sub last_modified { shift->_date_header( 'last-modified', @_ ); } | ||||||||||||||||||||||||||
|
Subroutine
last_modified: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | # This is used as a private LWP extension. The Client-Date header is | ||||||||||||||||||||||||||||
| 266 | # added as a timestamp to a response when it has been received. | ||||||||||||||||||||||||||||
| 267 | 0 | ▶ | sub client_date { shift->_date_header( 'client-date', @_ ); } | ||||||||||||||||||||||||||
|
Subroutine
client_date: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||
| 269 | 0 | ▶ | sub content_is_text { | ||||||||||||||||||||||||||
|
Subroutine
content_is_text: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 270 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 271 | 0 | return $self->content_type =~ m{^text/}; | |||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | 2 | ▶ | sub content_is_html { | ||||||||||||||||||||||||||
|
Subroutine
content_is_html: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 275 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 276 | 2 | ▶ | return $self->content_type eq 'text/html' || $self->content_is_xhtml; | ||||||||||||||||||||||||||
|
Condition66%2/3
$self->content_type eq 'text/html' || $self->content_is_xhtml
MC/DC0%0/2
$self->content_type eq 'text/html' || $self->content_is_xhtml
$self->content_type eq 'text/html'
$self->content_is_xhtml
Truth table66%2/3
A || B
A= $self->content_type eq 'text/html'B= $self->content_is_xhtml
| |||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | 3 | ▶ | sub content_is_xhtml { | ||||||||||||||||||||||||||
|
Subroutine
content_is_xhtml: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 280 | 3 | my $ct = shift->content_type; | |||||||||||||||||||||||||||
| 281 | 3 | ▶ | 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'
| |||||||||||||||||||||||||||||
| 282 | || $ct eq "application/vnd.wap.xhtml+xml"; | ||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | 2 | ▶ | sub content_is_xml { | ||||||||||||||||||||||||||
|
Subroutine
content_is_xml: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||
| 286 | 2 | my $ct = shift->content_type; | |||||||||||||||||||||||||||
| 287 | 2 | ▶ | return 1 if $ct eq "text/xml"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 288 | 2 | ▶ | return 1 if $ct eq "application/xml"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 289 | 2 | ▶ | return 1 if $ct =~ /\+xml$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 290 | 1 | return 0; | |||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | 13 | 1; | |||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | __END__ | ||||||||||||||||||||||||||||