| 1 | package HTTP::Message; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 17 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 17 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 17 | our $VERSION = '7.04'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 17 | require HTTP::Headers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 17 | require Carp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 17 | our $MAXIMUM_BODY_SIZE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 17 | my $CRLF = "\015\012"; # "\r\n" is not portable | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 17 | ▶ | unless ($HTTP::URI_CLASS) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 17 | ▶ | if ($ENV{PERL_HTTP_URI_CLASS} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$ENV{"PERL_HTTP_URI_CLASS"} and $ENV{"PERL_HTTP_URI_CLASS"} =~ /^([\w:]+)$/
MC/DC0%0/2
$ENV{"PERL_HTTP_URI_CLASS"} and $ENV{"PERL_HTTP_URI_CLASS"} =~ /^([\w:]+)$/
$ENV{"PERL_HTTP_URI_CLASS"}
$ENV{"PERL_HTTP_URI_CLASS"} =~ /^([\w:]+)$/
Truth table33%1/3
A and B
A= $ENV{"PERL_HTTP_URI_CLASS"}B= $ENV{"PERL_HTTP_URI_CLASS"} =~ /^([\w:]+)$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | && $ENV{PERL_HTTP_URI_CLASS} =~ /^([\w:]+)$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 0 | $HTTP::URI_CLASS = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 17 | $HTTP::URI_CLASS = "URI"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 17 | ▶ | eval "require $HTTP::URI_CLASS"; die $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | *_utf8_downgrade = defined(&utf8::downgrade) ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 231 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 231 | ▶ | utf8::downgrade($_[0], 1) or | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | Carp::croak("HTTP::Message content must be bytes") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 17 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | sub new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 190 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 190 | my($class, $header, $content) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 190 | ▶ | if (defined $header) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 102 | ▶ | Carp::croak("Bad header argument") unless ref $header; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 101 | ▶ | if (ref($header) eq "ARRAY") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 79 | $header = HTTP::Headers->new(@$header); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 22 | $header = $header->clone; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 88 | $header = HTTP::Headers->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 189 | ▶ | if (defined $content) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 97 | _utf8_downgrade($content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 92 | $content = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 188 | bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | '_headers' => $header, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | '_content' => $content, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | '_max_body_size' => $HTTP::Message::MAXIMUM_BODY_SIZE, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | sub parse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 47 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 47 | my($class, $str) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 47 | my @hdr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 47 | while (1) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 81 | ▶ | if ($str =~ s/^([^\s:]+)[ \t]*: ?(.*)\n?//) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 29 | push(@hdr, $1, $2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 29 | $hdr[-1] =~ s/\r\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | ▶ | elsif (@hdr && $str =~ s/^([ \t].*)\n?//) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
@hdr and $str =~ s/^([ \t].*)\n?//
MC/DC100%2/2
@hdr and $str =~ s/^([ \t].*)\n?//
@hdr
$str =~ s/^([ \t].*)\n?//
Truth table100%3/3
A and B
A= @hdrB= $str =~ s/^([ \t].*)\n?//
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 5 | $hdr[-1] .= "\n$1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 5 | $hdr[-1] =~ s/\r\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 47 | $str =~ s/^\r?\n//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 47 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 47 | local $HTTP::Headers::TRANSLATE_UNDERSCORE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 47 | new($class, \@hdr, $str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | sub clone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 8 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clone: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 8 | my $clone = HTTP::Message->new($self->headers, | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | $self->content); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 8 | $clone->protocol($self->protocol); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 8 | $clone; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 4 | ▶ | sub clear { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 4 | $self->{_headers}->clear; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 4 | $self->content(""); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 4 | delete $self->{_parts}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 79 | ▶ | sub protocol { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
protocol: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 79 | shift->_elem('_protocol', @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 1153 | ▶ | sub headers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
headers: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 1153 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | # recalculation of _content might change headers, so we | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # need to force it now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 1153 | ▶ | $self->_content unless exists $self->{_content}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1153 | $self->{_headers}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 3 | ▶ | sub headers_as_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
headers_as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 3 | shift->headers->as_string(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 354 | ▶ | sub content { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 354 | my $self = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 354 | ▶ | if (defined(wantarray)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 246 | ▶ | $self->_content unless exists $self->{_content}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 246 | my $old = $self->{_content}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 246 | ▶ | $old = $$old if ref($old) eq "SCALAR"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 246 | ▶ | &_set_content if @_ > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 246 | return $old; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 108 | ▶ | if (@_ > 1) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 106 | &_set_content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 2 | ▶ | Carp::carp("Useless content call in void context") if $^W; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 122 | ▶ | sub _set_content { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_content: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 122 | my $self = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 122 | _utf8_downgrade($_[1]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 121 | ▶ | if (!ref($_[1]) && ref($self->{_content}) eq "SCALAR") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not ref $_[1] and ref $self->{"_content"} eq "SCALAR"
MC/DC100%2/2
not ref $_[1] and ref $self->{"_content"} eq "SCALAR"
not ref $_[1]
ref $self->{"_content"} eq "SCALAR"
Truth table100%3/3
not(A) and B
A= not ref $_[1]B= ref $self->{"_content"} eq "SCALAR"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 3 | ▶ | ${$self->{_content}} = defined( $_[1] ) ? $_[1] : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 118 | ▶ | die "Can't set content to be a scalar reference" if ref($_[1]) eq "SCALAR"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 117 | ▶ | $self->{_content} = defined( $_[1] ) ? $_[1] : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 117 | delete $self->{_content_ref}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 119 | ▶ | delete $self->{_parts} unless $_[2]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | sub add_content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 12 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_content: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 12 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 12 | ▶ | $self->_content unless exists $self->{_content}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 12 | my $chunkref = \$_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 12 | ▶ | $chunkref = $$chunkref if ref($$chunkref); # legacy | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 12 | _utf8_downgrade($$chunkref); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 11 | my $ref = ref($self->{_content}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 11 | ▶ | if (!$ref) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 9 | $self->{_content} .= $$chunkref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | elsif ($ref eq "SCALAR") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 1 | ${$self->{_content}} .= $$chunkref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | Carp::croak("Can't append to $ref content"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 10 | delete $self->{_parts}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 2 | ▶ | sub add_content_utf8 { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_content_utf8: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | my($self, $buf) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 2 | utf8::upgrade($buf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | utf8::encode($buf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 2 | $self->add_content($buf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | sub content_ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 140 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_ref: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 140 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 140 | ▶ | $self->_content unless exists $self->{_content}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 140 | delete $self->{_parts}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 140 | my $old = \$self->{_content}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 140 | my $old_cref = $self->{_content_ref}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 140 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 6 | my $new = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 6 | ▶ | Carp::croak("Setting content_ref to a non-ref") unless ref($new); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 5 | delete $self->{_content}; # avoid modifying $$old | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 5 | $self->{_content} = $new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 5 | $self->{_content_ref}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 139 | ▶ | $old = $$old if $old_cref; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 139 | return $old; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | sub content_charset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 53 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
content_charset: called CC=30 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 53 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 53 | ▶ | if (my $charset = $self->content_type_charset) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | return $charset; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # time to start guessing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 52 | my $cref = $self->decoded_content(ref => 1, charset => "none"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # Unicode BOM | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 52 | for ($$cref) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 52 | ▶ | return "UTF-8" if /^\xEF\xBB\xBF/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 50 | ▶ | return "UTF-32LE" if /^\xFF\xFE\x00\x00/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 49 | ▶ | return "UTF-32BE" if /^\x00\x00\xFE\xFF/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 48 | ▶ | return "UTF-16LE" if /^\xFF\xFE/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 44 | ▶ | return "UTF-16BE" if /^\xFE\xFF/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 43 | ▶ | if ($self->content_is_xml) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | # http://www.w3.org/TR/2006/REC-xml-20060816/#sec-guessing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | # XML entity not accompanied by external encoding information and not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | # in UTF-8 or UTF-16 encoding must begin with an XML encoding declaration, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | # in which the first characters must be '<?xml' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 15 | for ($$cref) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 15 | ▶ | return "UTF-32BE" if /^\x00\x00\x00</; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 14 | ▶ | return "UTF-32LE" if /^<\x00\x00\x00/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 13 | ▶ | return "UTF-16BE" if /^(?:\x00\s)*\x00</; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 12 | ▶ | return "UTF-16LE" if /^(?:\s\x00)*<\x00/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 11 | ▶ | if (/^\s*(<\?xml[^\x00]*?\?>)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 4 | ▶ | if ($1 =~ /\sencoding\s*=\s*(["'])(.*?)\1/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 4 | my $enc = $2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 4 | $enc =~ s/^\s+//; $enc =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 4 | ▶ | return $enc if $enc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 8 | return "UTF-8"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | elsif ($self->content_is_html) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | # look for <META charset="..."> or <META content="..."> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | # http://dev.w3.org/html5/spec/Overview.html#determining-the-character-encoding | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 4 | require IO::HTML; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # Use relaxed search to match previous versions of HTTP::Message: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 4 | my $encoding = IO::HTML::find_charset_in($$cref, { encoding => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | need_pragma => 0 }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 4 | ▶ | return $encoding->mime_name if $encoding; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | elsif ($self->content_type eq "application/json") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 6 | for ($$cref) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | # RFC 4627, ch 3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 6 | ▶ | return "UTF-32BE" if /^\x00\x00\x00./s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 5 | ▶ | return "UTF-32LE" if /^.\x00\x00\x00/s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 3 | ▶ | return "UTF-16BE" if /^\x00.\x00./s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 2 | ▶ | return "UTF-16LE" if /^.\x00.\x00/s; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 1 | return "UTF-8"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 19 | ▶ | if ($self->content_type =~ /^text\//) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 18 | for ($$cref) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 18 | ▶ | if (length) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 17 | ▶ | return "US-ASCII" unless /[\x80-\xFF]/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 3 | require Encode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 3 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 3 | Encode::decode_utf8($_, Encode::FB_CROAK() | Encode::LEAVE_SRC()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 3 | ▶ | return "UTF-8" unless $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 1 | return "ISO-8859-1"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 2 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 138 | ▶ | sub max_body_size { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
max_body_size: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 138 | my $self = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 138 | my $old = $self->{_max_body_size}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 138 | ▶ | $self->_set_max_body_size($_[1]) if @_ > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 138 | return $old; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 7 | ▶ | sub _set_max_body_size { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_max_body_size: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 7 | my $self = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 7 | $self->{_max_body_size} = $_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | sub decoded_content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 120 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decoded_content: called CC=65 SCAR=42.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 120 | my($self, %opt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 120 | my $content_ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | my $content_ref_iscopy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 120 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 120 | $content_ref = $self->content_ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 120 | ▶ | die "Can't decode ref content" if ref($content_ref) ne "SCALAR"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | my $content_limit = exists $opt{ max_body_size } ? $opt{ max_body_size } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 120 | ▶ | : defined $self->max_body_size ? $self->max_body_size | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | : undef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 120 | my %limiter_options; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 120 | ▶ | if( defined $content_limit ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 8 | %limiter_options = (LimitOutput => 1, Bufsize => $content_limit); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 120 | ▶ | if (my $h = $self->header("Content-Encoding")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 62 | $h =~ s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 62 | $h =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 62 | for my $ce (reverse split(/\s*,\s*/, lc($h))) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 107 | ▶ | next unless $ce; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 107 | ▶ | next if $ce eq "identity" || $ce eq "none"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$ce eq "identity" or $ce eq "none"
MC/DC100%2/2
$ce eq "identity" or $ce eq "none"
$ce eq "identity"
$ce eq "none"
Truth table100%3/3
A or B
A= $ce eq "identity"B= $ce eq "none"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 103 | ▶ | if ($ce eq "gzip" || $ce eq "x-gzip") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
Condition100%3/3
$ce eq "gzip" or $ce eq "x-gzip"
MC/DC100%2/2
$ce eq "gzip" or $ce eq "x-gzip"
$ce eq "gzip"
$ce eq "x-gzip"
Truth table100%3/3
A or B
A= $ce eq "gzip"B= $ce eq "x-gzip"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 30 | require Compress::Raw::Zlib; # 'WANT_GZIP_OR_ZLIB', 'Z_BUF_ERROR'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 30 | ▶ | if( ! $content_ref_iscopy and keys %limiter_options) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $content_ref_iscopy and keys %limiter_options
MC/DC100%2/2
not $content_ref_iscopy and keys %limiter_options
not $content_ref_iscopy
keys %limiter_options
Truth table100%3/3
not(A) and B
A= not $content_ref_iscopyB= keys %limiter_options
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | # Create a copy of the input because Zlib will overwrite it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | # :-( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 2 | my $input = "$$content_ref"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 2 | $content_ref = \$input; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 2 | $content_ref_iscopy++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 30 | my ($i, $status) = Compress::Raw::Zlib::Inflate->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | %limiter_options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | ConsumeInput => 0, # overridden by Zlib if we have %limiter_options :-( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | WindowBits => Compress::Raw::Zlib::WANT_GZIP_OR_ZLIB(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 30 | my $res = $i->inflate( $content_ref, \my $output ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 30 | ▶ | $res == Compress::Raw::Zlib::Z_BUF_ERROR() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | and Carp::croak("Decoded content would be larger than $content_limit octets"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 28 | ▶ | $res == Compress::Raw::Zlib::Z_OK() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$res == Compress::Raw::Zlib::Z_OK() or $res == Compress::Raw::Zlib::Z_STREAM_END()
MC/DC0%0/2
$res == Compress::Raw::Zlib::Z_OK() or $res == Compress::Raw::Zlib::Z_STREAM_END()
$res == Compress::Raw::Zlib::Z_OK()
$res == Compress::Raw::Zlib::Z_STREAM_END()
Truth table33%1/3
A or B
A= $res == Compress::Raw::Zlib::Z_OK()B= $res == Compress::Raw::Zlib::Z_STREAM_END()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | or $res == Compress::Raw::Zlib::Z_STREAM_END() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | or die "Can't gunzip content: $res"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 28 | $content_ref = \$output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 28 | $content_ref_iscopy++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | elsif ($ce eq 'br') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 14 | require IO::Uncompress::Brotli; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 14 | my $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 14 | ▶ | if( defined $content_limit ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | # unbro() is the only brotli interface that takes a size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | # limit; the streaming decompress() method cannot stop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | # short. It decodes into a buffer of $content_limit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | # octets, so the limit bounds the allocation directly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 4 | $output = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 4 | IO::Uncompress::Brotli::unbro($$content_ref, $content_limit); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | # Brotli reports "output buffer too small" and "this is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | # not valid brotli" identically, so, unlike the gzip and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | # bzip2 branches, we cannot say for certain which it was. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 4 | ▶ | $@ and $@ =~ /BrotliDecoderDecompress/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$@ and $@ =~ /BrotliDecoderDecompress/
MC/DC50%1/2
$@ and $@ =~ /BrotliDecoderDecompress/
$@
$@ =~ /BrotliDecoderDecompress/
Truth table66%2/3
A and B
A= $@B= $@ =~ /BrotliDecoderDecompress/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | and Carp::croak("Can't unbrotli content: it is corrupt, or would decode to more than $content_limit octets"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 10 | my $bro = IO::Uncompress::Brotli->create; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 10 | $output = eval { $bro->decompress($$content_ref) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 12 | ▶ | $@ and die "Can't unbrotli content: $@"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 12 | $content_ref = \$output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 12 | $content_ref_iscopy++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | ▶ | elsif ($ce eq "x-bzip2" or $ce eq "bzip2") { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$ce eq "x-bzip2" or $ce eq "bzip2"
MC/DC100%2/2
$ce eq "x-bzip2" or $ce eq "bzip2"
$ce eq "x-bzip2"
$ce eq "bzip2"
Truth table100%3/3
A or B
A= $ce eq "x-bzip2"B= $ce eq "bzip2"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 28 | require Compress::Raw::Bzip2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 28 | ▶ | if( ! $content_ref_iscopy ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | # Create a copy of the input because Bzlib2 will overwrite it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | # :-( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 12 | my $input = "$$content_ref"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 12 | $content_ref = \$input; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 12 | $content_ref_iscopy++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | my ($i, $status) = Compress::Raw::Bunzip2->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 1, # appendInput | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0, # consumeInput | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0, # small | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 28 | ▶ | $limiter_options{ LimitOutput } || 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$limiter_options{'LimitOutput'} || 0
MC/DC100%1/1
$limiter_options{'LimitOutput'} || 0
$limiter_options{'LimitOutput'}
Truth table100%2/2
A
A= $limiter_options{'LimitOutput'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 28 | my $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | $output = "\0" x $limiter_options{ Bufsize } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | 28 | ▶ | if $limiter_options{ Bufsize }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 28 | my $res = $i->bzinflate( $content_ref, \$output ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 28 | ▶ | $res == Compress::Raw::Bzip2::BZ_OUTBUFF_FULL() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | and Carp::croak("Decoded content would be larger than $content_limit octets"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 28 | ▶ | $res == Compress::Raw::Bzip2::BZ_OK() | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$res == Compress::Raw::Bzip2::BZ_OK() or $res == Compress::Raw::Bzip2::BZ_STREAM_END()
MC/DC50%1/2
$res == Compress::Raw::Bzip2::BZ_OK() or $res == Compress::Raw::Bzip2::BZ_STREAM_END()
$res == Compress::Raw::Bzip2::BZ_OK()
$res == Compress::Raw::Bzip2::BZ_STREAM_END()
Truth table66%2/3
A or B
A= $res == Compress::Raw::Bzip2::BZ_OK()B= $res == Compress::Raw::Bzip2::BZ_STREAM_END()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | or $res == Compress::Raw::Bzip2::BZ_STREAM_END() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | or die "Can't bunzip content: $res"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 26 | $content_ref = \$output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 26 | $content_ref_iscopy++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | elsif ($ce eq "deflate") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 6 | require IO::Uncompress::Inflate; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 6 | my $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 6 | my $status = IO::Uncompress::Inflate::inflate($content_ref, \$output, Transparent => 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 6 | my $error = $IO::Uncompress::Inflate::InflateError; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 6 | ▶ | unless ($status) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | # "Content-Encoding: deflate" is supposed to mean the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | # "zlib" format of RFC 1950, but Microsoft got that | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | # wrong, so some servers sends the raw compressed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | # "deflate" data. This tries to inflate this format. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 2 | $output = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 2 | require IO::Uncompress::RawInflate; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 2 | ▶ | unless (IO::Uncompress::RawInflate::rawinflate($content_ref, \$output)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | $self->push_header("Client-Warning" => | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | "Could not raw inflate content: $IO::Uncompress::RawInflate::RawInflateError"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | $output = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 6 | ▶ | die "Can't inflate content: $error" unless defined $output; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 6 | $content_ref = \$output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 6 | $content_ref_iscopy++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | ▶ | elsif ($ce eq "compress" || $ce eq "x-compress") { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$ce eq "compress" or $ce eq "x-compress"
MC/DC100%2/2
$ce eq "compress" or $ce eq "x-compress"
$ce eq "compress"
$ce eq "x-compress"
Truth table100%3/3
A or B
A= $ce eq "compress"B= $ce eq "x-compress"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 2 | die "Can't uncompress content"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | elsif ($ce eq "base64") { # not really C-T-E, but should be harmless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 19 | require MIME::Base64; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 19 | $content_ref = \MIME::Base64::decode($$content_ref); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 19 | $content_ref_iscopy++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | elsif ($ce eq "quoted-printable") { # not really C-T-E, but should be harmless | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 1 | require MIME::QuotedPrint; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 1 | $content_ref = \MIME::QuotedPrint::decode($$content_ref); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 1 | $content_ref_iscopy++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 3 | die "Don't know how to decode Content-Encoding '$ce'"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 109 | ▶ | if ($self->content_is_text || (my $is_xml = $self->content_is_xml)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->content_is_text or my $is_xml = $self->content_is_xml
MC/DC100%2/2
$self->content_is_text or my $is_xml = $self->content_is_xml
$self->content_is_text
my $is_xml = $self->content_is_xml
Truth table100%3/3
A or B
A= $self->content_is_textB= my $is_xml = $self->content_is_xml
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | my $charset = lc( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | $opt{charset} || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | $self->content_type_charset || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | $opt{default_charset} || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 100 | ▶ | $self->content_charset || | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition81%9/11
$opt{'charset'} || $self->content_type_charset || $opt{'default_charset'} || $self->content_charset || 'ISO-8859-1'
$opt{"charset"} or $self->content_type_charset or $opt{"default_charset"} or $self->content_charset
$opt{"charset"} or $self->content_type_charset or $opt{"default_charset"}
$opt{"charset"} or $self->content_type_charset
MC/DC0%0/4
$opt{'charset'} || $self->content_type_charset || $opt{'default_charset'} || $self->content_charset || 'ISO-8859-1'
$opt{"charset"}
$self->content_type_charset
$opt{"default_charset"}
$self->content_charset
Truth table80%4/5
A or B or C or D
A= $opt{"charset"}B= $self->content_type_charsetC= $opt{"default_charset"}D= $self->content_charset
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | "ISO-8859-1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 100 | ▶ | if ($charset eq "none") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | # leave it as is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | ▶ | elsif ($charset eq "us-ascii" || $charset eq "iso-8859-1") { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$charset eq "us-ascii" or $charset eq "iso-8859-1"
MC/DC100%2/2
$charset eq "us-ascii" or $charset eq "iso-8859-1"
$charset eq "us-ascii"
$charset eq "iso-8859-1"
Truth table100%3/3
A or B
A= $charset eq "us-ascii"B= $charset eq "iso-8859-1"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 15 | ▶ | if ($$content_ref =~ /[^\x00-\x7F]/ && defined &utf8::upgrade) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$$content_ref =~ /[^\x00-\x7F]/ and defined &utf8::upgrade
MC/DC50%1/2
$$content_ref =~ /[^\x00-\x7F]/ and defined &utf8::upgrade
$$content_ref =~ /[^\x00-\x7F]/
defined &utf8::upgrade
Truth table66%2/3
A and B
A= $$content_ref =~ /[^\x00-\x7F]/B= defined &utf8::upgrade
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 3 | ▶ | unless ($content_ref_iscopy) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 3 | my $copy = $$content_ref; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 3 | $content_ref = \$copy; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 3 | $content_ref_iscopy++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 3 | utf8::upgrade($$content_ref); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 27 | require Encode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 27 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | $content_ref = \Encode::decode($charset, $$content_ref, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 27 | ▶ | ($opt{charset_strict} ? Encode::FB_CROAK() : 0) | Encode::LEAVE_SRC()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 27 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 4 | my $retried; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 4 | ▶ | if ($@ =~ /^Unknown encoding/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 3 | ▶ | my $alt_charset = lc($opt{alt_charset} || ""); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opt{'alt_charset'} || ''
MC/DC100%1/1
$opt{'alt_charset'} || ''
$opt{'alt_charset'}
Truth table100%2/2
A
A= $opt{'alt_charset'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 3 | ▶ | if ($alt_charset && $charset ne $alt_charset) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$alt_charset and $charset ne $alt_charset
MC/DC50%1/2
$alt_charset and $charset ne $alt_charset
$alt_charset
$charset ne $alt_charset
Truth table66%2/3
A and B
A= $alt_charsetB= $charset ne $alt_charset
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | # Retry decoding with the alternative charset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | $content_ref = \Encode::decode($alt_charset, $$content_ref, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 2 | ▶ | ($opt{charset_strict} ? Encode::FB_CROAK() : 0) | Encode::LEAVE_SRC()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | unless $alt_charset eq "none"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 2 | $retried++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 4 | ▶ | die unless $retried; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 25 | ▶ | die "Encode::decode() returned undef improperly" unless defined $$content_ref; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 25 | ▶ | if ($is_xml) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | # Get rid of the XML encoding declaration if present | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 10 | $$content_ref =~ s/^\x{FEFF}//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 10 | ▶ | if ($$content_ref =~ /^(\s*<\?xml[^\x00]*?\?>)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 4 | substr($$content_ref, 0, length($1)) =~ s/\sencoding\s*=\s*(["']).*?\1//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 120 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 13 | ▶ | Carp::croak($@) if $opt{raise_error}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 4 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 107 | ▶ | return $opt{ref} ? $content_ref : $$content_ref; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | sub decodable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 4 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decodable: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | # should match the Content-Encoding values that decoded_content can deal with | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 4 | my @enc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 4 | local $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | # XXX preferably we should determine if the modules are available without loading | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | # them here | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 4 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 4 | require Compress::Raw::Zlib; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 4 | push(@enc, "gzip", "x-gzip"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 4 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 4 | require IO::Uncompress::Inflate; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 4 | require IO::Uncompress::RawInflate; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 4 | push(@enc, "deflate"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 4 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 4 | require Compress::Raw::Bzip2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 4 | push(@enc, "x-bzip2", "bzip2"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 4 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 4 | require IO::Uncompress::Brotli; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 4 | push(@enc, 'br'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | # we don't care about announcing the 'identity', 'base64' and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | # 'quoted-printable' stuff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 4 | ▶ | return wantarray ? @enc : join(", ", @enc); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | sub decode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 12 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
decode: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 12 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 12 | ▶ | return 1 unless $self->header("Content-Encoding"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 11 | ▶ | if (defined(my $content = $self->decoded_content(charset => "none"))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 10 | $self->remove_header("Content-Encoding", "Content-Length", "Content-MD5"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 10 | $self->content($content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 10 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | sub encode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 13 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
encode: called CC=20 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 13 | my($self, @enc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 13 | ▶ | Carp::croak("Can't encode multipart/* messages") if $self->content_type =~ m,^multipart/,; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 12 | ▶ | Carp::croak("Can't encode message/* messages") if $self->content_type =~ m,^message/,; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 11 | ▶ | return 1 unless @enc; # nothing to do | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 10 | my $content = $self->content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 10 | for my $encoding (@enc) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 12 | ▶ | if ($encoding eq "identity" || $encoding eq "none") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
Condition100%3/3
$encoding eq "identity" or $encoding eq "none"
MC/DC100%2/2
$encoding eq "identity" or $encoding eq "none"
$encoding eq "identity"
$encoding eq "none"
Truth table100%3/3
A or B
A= $encoding eq "identity"B= $encoding eq "none"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | # nothing to do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | elsif ($encoding eq "base64") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 2 | require MIME::Base64; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 2 | $content = MIME::Base64::encode($content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | ▶ | elsif ($encoding eq "gzip" || $encoding eq "x-gzip") { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$encoding eq "gzip" or $encoding eq "x-gzip"
MC/DC100%2/2
$encoding eq "gzip" or $encoding eq "x-gzip"
$encoding eq "gzip"
$encoding eq "x-gzip"
Truth table100%3/3
A or B
A= $encoding eq "gzip"B= $encoding eq "x-gzip"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 2 | require IO::Compress::Gzip; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 2 | my $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 2 | ▶ | IO::Compress::Gzip::gzip(\$content, \$output, Minimal => 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | or die "Can't gzip content: $IO::Compress::Gzip::GzipError"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 2 | $content = $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | elsif ($encoding eq "deflate") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 1 | require IO::Compress::Deflate; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 1 | my $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 1 | ▶ | IO::Compress::Deflate::deflate(\$content, \$output) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | or die "Can't deflate content: $IO::Compress::Deflate::DeflateError"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 1 | $content = $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | ▶ | elsif ($encoding eq "x-bzip2" || $encoding eq "bzip2") { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$encoding eq "x-bzip2" or $encoding eq "bzip2"
MC/DC100%2/2
$encoding eq "x-bzip2" or $encoding eq "bzip2"
$encoding eq "x-bzip2"
$encoding eq "bzip2"
Truth table100%3/3
A or B
A= $encoding eq "x-bzip2"B= $encoding eq "bzip2"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 2 | require IO::Compress::Bzip2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 2 | my $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 2 | ▶ | IO::Compress::Bzip2::bzip2(\$content, \$output) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | or die "Can't bzip2 content: $IO::Compress::Bzip2::Bzip2Error"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 2 | $content = $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | elsif ($encoding eq "br") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 1 | require IO::Compress::Brotli; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 1 | my $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 1 | ▶ | eval { $output = IO::Compress::Brotli::bro($content) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | or die "Can't brotli content: $@"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 1 | $content = $output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | elsif ($encoding eq "rot13") { # for the fun of it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 1 | $content =~ tr/A-Za-z/N-ZA-Mn-za-m/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 1 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 9 | my $h = $self->header("Content-Encoding"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 9 | ▶ | unshift(@enc, $h) if $h; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 9 | $self->header("Content-Encoding", join(", ", @enc)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 9 | $self->remove_header("Content-Length", "Content-MD5"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 9 | $self->content($content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 9 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | sub as_string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 91 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 91 | my($self, $eol) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 91 | ▶ | $eol = "\n" unless defined $eol; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | # The calculation of content might update the headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | # so we need to do that first. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 91 | my $content = $self->content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 91 | ▶ | return join("", $self->{'_headers'}->as_string($eol), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
@_ == 1 and length $content and not $content =~ /\n\z/
@_ == 1 and length $content
MC/DC100%3/3
@_ == 1 and length $content and not $content =~ /\n\z/
@_ == 1
length $content
not $content =~ /\n\z/
Truth table100%4/4
A and B and not(C)
A= @_ == 1B= length $contentC= not $content =~ /\n\z/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | $eol, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | $content, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | (@_ == 1 && length($content) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | $content !~ /\n\z/) ? "\n" : "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | sub dump | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 15 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump: called CC=12 SCAR=24.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 15 | my($self, %opt) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 15 | my $content = $self->content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 15 | my $chopped = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 15 | ▶ | if (!ref($content)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 15 | my $maxlen = $opt{maxlength}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 15 | ▶ | $maxlen = 512 unless defined($maxlen); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 15 | ▶ | if ($maxlen && length($content) > $maxlen * 1.1 + 3) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$maxlen and length $content > $maxlen * "1.1" + 3
MC/DC100%2/2
$maxlen and length $content > $maxlen * "1.1" + 3
$maxlen
length $content > $maxlen * "1.1" + 3
Truth table100%3/3
A and B
A= $maxlenB= length $content > $maxlen * "1.1" + 3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 1 | $chopped = length($content) - $maxlen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 1 | $content = substr($content, 0, $maxlen) . "..."; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 15 | $content =~ s/\\/\\\\/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 15 | $content =~ s/\t/\\t/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 15 | $content =~ s/\r/\\r/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | # no need for 3 digits in escape for these | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 15 | $content =~ s/([\0-\11\13-\037])(?!\d)/sprintf('\\%o',ord($1))/eg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 15 | $content =~ s/([\0-\11\13-\037\177-\377])/sprintf('\\x%02X',ord($1))/eg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | $content =~ s/([^\12\040-\176])/sprintf('\\x{%X}',ord($1))/eg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | # remaining whitespace | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | $content =~ s/( +)\n/("\\40" x length($1)) . "\n"/eg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | $content =~ s/(\n+)\n/("\\n" x length($1)) . "\n"/eg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 15 | $content =~ s/\n\z/\\n/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 15 | my $no_content = $opt{no_content}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 15 | ▶ | $no_content = "(no content)" unless defined $no_content; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 15 | ▶ | if ($content eq $no_content) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | # escape our $no_content marker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 2 | $content =~ s/^(.)/sprintf('\\x%02X',ord($1))/eg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | elsif ($content eq "") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 8 | $content = $no_content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 15 | my @dump; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 15 | ▶ | push(@dump, $opt{preheader}) if $opt{preheader}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 15 | push(@dump, $self->{_headers}->as_string, $content); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 15 | ▶ | push(@dump, "(+ $chopped more bytes not shown)") if $chopped; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 15 | my $dump = join("\n", @dump, ""); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 15 | ▶ | $dump =~ s/^/$opt{prefix}/gm if $opt{prefix}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 15 | ▶ | print $dump unless defined wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 15 | return $dump; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | # allow subclasses to override what will handle individual parts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 9 | ▶ | sub _part_class { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_part_class: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 9 | return __PACKAGE__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 27 | ▶ | sub parts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parts: called CC=11 SCAR=24.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 27 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 27 | ▶ | if (defined(wantarray) && (!exists $self->{_parts} || ref($self->{_content}) eq "SCALAR")) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined wantarray and !exists $self->{"_parts"} || ref $self->{"_content"} eq "SCALAR"
not exists $self->{"_parts"} or ref $self->{"_content"} eq "SCALAR"
MC/DC100%3/3
defined wantarray and !exists $self->{"_parts"} || ref $self->{"_content"} eq "SCALAR"
defined wantarray
not exists $self->{"_parts"}
ref $self->{"_content"} eq "SCALAR"
Truth table100%4/4
A and not(B) or C
A= defined wantarrayB= not exists $self->{"_parts"}C= ref $self->{"_content"} eq "SCALAR"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 13 | $self->_parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 27 | my $old = $self->{_parts}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 27 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 8 | ▶ | my @parts = map { ref($_) eq 'ARRAY' ? @$_ : $_ } @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 8 | ▶ | my $ct = $self->content_type || ""; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->content_type || ''
MC/DC100%1/1
$self->content_type || ''
$self->content_type
Truth table100%2/2
A
A= $self->content_type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 8 | ▶ | if ($ct =~ m,^message/,) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 3 | ▶ | Carp::croak("Only one part allowed for $ct content") | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | if @parts > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | elsif ($ct !~ m,^multipart/,) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 3 | $self->remove_content_headers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 3 | $self->content_type("multipart/mixed"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 7 | $self->{_parts} = \@parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | 7 | _stale_content($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 26 | ▶ | return @$old if wantarray; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 11 | return $old->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 4 | ▶ | sub add_part { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_part: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 4 | ▶ | if (($self->content_type || "") !~ m,^multipart/,) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%2/2
$self->content_type || ''
MC/DC100%1/1
$self->content_type || ''
$self->content_type
Truth table100%2/2
A
A= $self->content_type
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 2 | my $p = $self->_part_class->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | $self->remove_content_headers, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | $self->content(""), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 2 | $self->content_type("multipart/mixed"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 2 | $self->{_parts} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 2 | ▶ | if ($p->headers->header_field_names || $p->content ne "") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$p->headers->header_field_names or $p->content ne ""
MC/DC50%1/2
$p->headers->header_field_names or $p->content ne ""
$p->headers->header_field_names
$p->content ne ""
Truth table66%2/3
A or B
A= $p->headers->header_field_namesB= $p->content ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 1 | push(@{$self->{_parts}}, $p); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | ▶ | elsif (!exists $self->{_parts} || ref($self->{_content}) eq "SCALAR") { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
not exists $self->{"_parts"} or ref $self->{"_content"} eq "SCALAR"
MC/DC50%1/2
not exists $self->{"_parts"} or ref $self->{"_content"} eq "SCALAR"
not exists $self->{"_parts"}
ref $self->{"_content"} eq "SCALAR"
Truth table66%2/3
not(A) or B
A= not exists $self->{"_parts"}B= ref $self->{"_content"} eq "SCALAR"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 1 | $self->_parts; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 4 | push(@{$self->{_parts}}, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 4 | _stale_content($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 11 | ▶ | sub _stale_content { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stale_content: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 11 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 11 | ▶ | if (ref($self->{_content}) eq "SCALAR") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | # must recalculate now | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 1 | $self->_content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | # just invalidate cache | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 10 | delete $self->{_content}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 10 | delete $self->{_content_ref}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | # delegate all other method calls to the headers object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 17 | our $AUTOLOAD; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 75 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 75 | my ( $package, $method ) = $AUTOLOAD =~ m/\A(.+)::([^:]*)\z/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 75 | my $code = $_[0]->can($method); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 75 | ▶ | Carp::croak( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | qq(Can't locate object method "$method" via package "$package")) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | unless $code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 72 | goto &$code; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 129 | ▶ | sub can { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
can: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 129 | my ( $self, $method ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 129 | ▶ | if ( my $own_method = $self->SUPER::can($method) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 20 | return $own_method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 109 | ▶ | my $headers = ref($self) ? $self->headers : 'HTTP::Headers'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | 109 | ▶ | if ( $headers->can($method) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | # We create the function here so that it will not need to be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | # autoloaded or recreated the next time. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 17 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 1027 | ▶ | *$method = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 1027 | local $Carp::Internal{ +__PACKAGE__ } = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 1027 | shift->headers->$method(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 74 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 74 | return \&$method; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 35 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 1 | ▶ | sub DESTROY { } # avoid AUTOLOADing it | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | # Private method to access members in %$self | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | sub _elem | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 404 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_elem: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 404 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 404 | my $elem = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 404 | my $old = $self->{$elem}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 404 | ▶ | $self->{$elem} = $_[0] if @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 404 | return $old; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | # Create private _parts attribute from current _content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | 14 | ▶ | sub _parts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parts: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 14 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 14 | my $ct = $self->content_type; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 14 | ▶ | if ($ct =~ m,^multipart/,) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 4 | require HTTP::Headers::Util; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 4 | my @h = HTTP::Headers::Util::split_header_words($self->header("Content-Type")); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | 4 | ▶ | die "Assert" unless @h; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 4 | my %h = @{$h[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 4 | ▶ | if (defined(my $b = $h{boundary})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 3 | my $str = $self->content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 3 | $str =~ s/\r?\n--\Q$b\E--.*//s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 3 | ▶ | if ($str =~ s/(^|.*?\r?\n)--\Q$b\E\r?\n//s) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 3 | $self->{_parts} = [map $self->_part_class->parse($_), | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | split(/\r?\n--\Q$b\E\r?\n/, $str)] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | elsif ($ct eq "message/http") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 4 | require HTTP::Request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 4 | require HTTP::Response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 4 | my $content = $self->content; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 4 | ▶ | my $class = ($content =~ m,^(HTTP/.*)\n,) ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | "HTTP::Response" : "HTTP::Request"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 4 | $self->{_parts} = [$class->parse($content)]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | elsif ($ct =~ m,^message/,) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 2 | $self->{_parts} = [ $self->_part_class->parse($self->content) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 14 | ▶ | $self->{_parts} ||= []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"_parts"} ||= []
MC/DC100%1/1
$self->{"_parts"} ||= []
$self->{"_parts"}
Truth table100%2/2
A
A= $self->{"_parts"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | # Create private _content attribute from current _parts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 10 | ▶ | sub _content { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_content: called CC=10 SCAR=23.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 10 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | 10 | ▶ | my $ct = $self->{_headers}->header("Content-Type") || "multipart/mixed"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'_headers'}->header('Content-Type') || 'multipart/mixed'
MC/DC0%0/1
$self->{'_headers'}->header('Content-Type') || 'multipart/mixed'
$self->{'_headers'}->header('Content-Type')
Truth table50%1/2
A
A= $self->{'_headers'}->header('Content-Type')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 10 | ▶ | if ($ct =~ m,^\s*message/,i) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 2 | _set_content($self, $self->{_parts}[0]->as_string($CRLF), 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 8 | require HTTP::Headers::Util; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 8 | my @v = HTTP::Headers::Util::split_header_words($ct); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 8 | ▶ | Carp::carp("Multiple Content-Type headers") if @v > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 8 | @v = @{$v[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 8 | my $boundary; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | my $boundary_index; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 8 | ▶ | for (my @tmp = @v; @tmp;) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 10 | my($k, $v) = splice(@tmp, 0, 2); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 10 | ▶ | if ($k eq "boundary") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 2 | $boundary = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 2 | $boundary_index = @v - @tmp - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 2 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 8 | my @parts = map $_->as_string($CRLF), @{$self->{_parts}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 8 | my $bno = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 8 | ▶ | $boundary = _boundary() unless defined $boundary; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | CHECK_BOUNDARY: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 8 | for (@parts) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 15 | ▶ | if (index($_, $boundary) >= 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | # must have a better boundary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 1 | $boundary = _boundary(++$bno); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 1 | redo CHECK_BOUNDARY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 8 | ▶ | if ($boundary_index) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 2 | $v[$boundary_index] = $boundary; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 6 | push(@v, boundary => $boundary); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 8 | $ct = HTTP::Headers::Util::join_header_words(@v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 8 | $self->{_headers}->header("Content-Type", $ct); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 8 | _set_content($self, "--$boundary$CRLF" . | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | join("$CRLF--$boundary$CRLF", @parts) . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | "$CRLF--$boundary--$CRLF", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | sub _boundary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | 7 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_boundary: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 7 | ▶ | my $size = shift || return "xYzZY"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || (return 'xYzZY')
MC/DC100%1/1
shift() || (return 'xYzZY')
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 1 | require MIME::Base64; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 1 | my $b = MIME::Base64::encode(join("", map chr(rand(256)), 1..$size*3), ""); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 1 | $b =~ s/[\W]/X/g; # ensure alnum only | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 1 | $b; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 17 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | =encoding UTF-8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | HTTP::Message - HTTP style message (base class) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | version 7.04 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | use parent 'HTTP::Message'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | An C<HTTP::Message> object contains some headers and a content body. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | The following methods are available: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | =item $mess = HTTP::Message->new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | =item $mess = HTTP::Message->new( $headers ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | =item $mess = HTTP::Message->new( $headers, $content ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | This constructs a new message object. Normally you would want | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | construct C<HTTP::Request> or C<HTTP::Response> objects instead. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | The optional $header argument should be a reference to an | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | C<HTTP::Headers> object or a plain array reference of key/value pairs. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | If an C<HTTP::Headers> object is provided then a copy of it will be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | embedded into the constructed message, i.e. it will not be owned and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | can be modified afterwards without affecting the message. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | The optional $content argument should be a string of bytes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | =item $mess = HTTP::Message->parse( $str ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | This constructs a new message object by parsing the given string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | =item $mess->headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | Returns the embedded C<HTTP::Headers> object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | =item $mess->headers_as_string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | =item $mess->headers_as_string( $eol ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | Call the as_string() method for the headers in the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | message. This will be the same as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | $mess->headers->as_string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | but it will make your program a whole character shorter :-) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | =item $mess->content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | =item $mess->content( $bytes ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | The content() method sets the raw content if an argument is given. If no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | argument is given the content is not touched. In either case the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | original raw content is returned. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | If the C<undef> argument is given, the content is reset to its default value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | which is an empty string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | Note that the content should be a string of bytes. Strings in perl | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | can contain characters outside the range of a byte. The C<Encode> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | module can be used to turn such strings into a string of bytes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | =item $mess->add_content( $bytes ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | The add_content() methods appends more data bytes to the end of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | current content buffer. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | =item $mess->add_content_utf8( $string ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | The add_content_utf8() method appends the UTF-8 bytes representing the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | string to the end of the current content buffer. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | =item $mess->content_ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | =item $mess->content_ref( \$bytes ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | The content_ref() method will return a reference to content buffer string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | It can be more efficient to access the content this way if the content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | is huge, and it can even be used for direct manipulation of the content, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | for instance: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | ${$res->content_ref} =~ s/\bfoo\b/bar/g; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | This example would modify the content buffer in-place. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | If an argument is passed it will setup the content to reference some | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | external source. The content() and add_content() methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | will automatically dereference scalar references passed this way. For | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | other references content() will return the reference itself and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | add_content() will refuse to do anything. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | =item $mess->content_charset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | This returns the charset used by the content in the message. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | charset is either found as the charset attribute of the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | C<Content-Type> header or by guessing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | See L<http://www.w3.org/TR/REC-html40/charset.html#spec-char-encoding> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | for details about how charset is determined. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | =item $mess->decoded_content( %options ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | Returns the content with any C<Content-Encoding> undone and, for textual content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | (C<Content-Type> values starting with C<text/>, exactly matching | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | C<application/xml>, or ending with C<+xml>), the raw content's character set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | decoded into Perl's Unicode string format. Note that this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | L<does not currently|https://github.com/libwww-perl/HTTP-Message/pull/99> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | attempt to decode declared character sets for any other content types like | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | C<application/json> or C<application/javascript>. If the C<Content-Encoding> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | or C<charset> of the message is unknown, this method will fail by returning | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | C<undef>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | The following options can be specified. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | =item C<charset> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | This overrides the charset parameter for text content. The value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | C<none> can used to suppress decoding of the charset. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | =item C<default_charset> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | This overrides the default charset guessed by content_charset() or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | if that fails "ISO-8859-1". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | =item C<alt_charset> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | If decoding fails because the charset specified in the Content-Type header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | isn't recognized by Perl's Encode module, then try decoding using this charset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | instead of failing. The C<alt_charset> might be specified as C<none> to simply | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | return the string without any decoding of charset as alternative. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | =item C<charset_strict> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | Abort decoding if malformed characters is found in the content. By | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | default you get the substitution character ("\x{FFFD}") in place of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | malformed characters. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | =item C<raise_error> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | If TRUE then raise an exception if not able to decode content. Reason | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | might be that the specified C<Content-Encoding> or C<charset> is not | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | supported. If this option is FALSE, then decoded_content() will return | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | C<undef> on errors, but will still set $@. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | =item C<ref> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | If TRUE then a reference to decoded content is returned. This might | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | be more efficient in cases where the decoded content is identical to | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | the raw content as no data copying is required in this case. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | =item $mess->decodable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | =item HTTP::Message::decodable() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | This returns the encoding identifiers that decoded_content() can | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | process. In scalar context returns a comma separated string of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | identifiers. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | This value is suitable for initializing the C<Accept-Encoding> request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | header field. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | =item $mess->decode | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | This method tries to replace the content of the message with the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | decoded version and removes the C<Content-Encoding> header. Returns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | TRUE if successful and FALSE if not. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | If the message does not have a C<Content-Encoding> header this method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | does nothing and returns TRUE. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | Note that the content of the message is still bytes after this method | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | has been called and you still need to call decoded_content() if you | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | want to process its content as a string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | =item $mess->encode( $encoding, ... ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | Apply the given encodings to the content of the message. Returns TRUE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | if successful. The "identity" (non-)encoding is always supported; other | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | currently supported encodings, subject to availability of required | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | additional modules, are "gzip", "deflate", "x-bzip2", "base64" and "br". | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | A successful call to this function will set the C<Content-Encoding> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | header. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | Note that C<multipart/*> or C<message/*> messages can't be encoded and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | this method will croak if you try. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | =item $mess->parts | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | =item $mess->parts( @parts ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | =item $mess->parts( \@parts ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | Messages can be composite, i.e. contain other messages. The composite | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | messages have a content type of C<multipart/*> or C<message/*>. This | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | method give access to the contained messages. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | The argumentless form will return a list of C<HTTP::Message> objects. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | If the content type of $msg is not C<multipart/*> or C<message/*> then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | this will return the empty list. In scalar context only the first | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | object is returned. The returned message parts should be regarded as | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | read-only (future versions of this library might make it possible | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | to modify the parent by modifying the parts). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | If the content type of $msg is C<message/*> then there will only be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | one part returned. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | If the content type is C<message/http>, then the return value will be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | either an C<HTTP::Request> or an C<HTTP::Response> object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | If a @parts argument is given, then the content of the message will be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | modified. The array reference form is provided so that an empty list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | can be provided. The @parts array should contain C<HTTP::Message> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | objects. The @parts objects are owned by $mess after this call and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | should not be modified or made part of other messages. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | When updating the message with this method and the old content type of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | $mess is not C<multipart/*> or C<message/*>, then the content type is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | set to C<multipart/mixed> and all other content headers are cleared. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | This method will croak if the content type is C<message/*> and more | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | than one part is provided. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | =item $mess->add_part( $part ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | This will add a part to a message. The $part argument should be | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | another C<HTTP::Message> object. If the previous content type of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | $mess is not C<multipart/*> then the old content (together with all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | content headers) will be made part #1 and the content type made | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | C<multipart/mixed> before the new part is added. The $part object is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | owned by $mess after this call and should not be modified or made part | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | of other messages. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | There is no return value. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | =item $mess->clear | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | Will clear the headers and set the content to the empty string. There | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | is no return value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | =item $mess->protocol | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | =item $mess->protocol( $proto ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | Sets the HTTP protocol used for the message. The protocol() is a string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | like C<HTTP/1.0> or C<HTTP/1.1>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | =item $mess->clone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | Returns a copy of the message object. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | =item $mess->as_string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | =item $mess->as_string( $eol ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | Returns the message formatted as a single string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | The optional $eol parameter specifies the line ending sequence to use. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | The default is "\n". If no $eol is given then as_string will ensure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | that the returned string is newline terminated (even when the message | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | content is not). No extra newline is appended if an explicit $eol is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | passed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | =item $mess->dump( %opt ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | Returns the message formatted as a string. In void context print the string. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | This differs from C<< $mess->as_string >> in that it escapes the bytes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | of the content so that it's safe to print them and it limits how much | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | content to print. The escapes syntax used is the same as for Perl's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | double quoted strings. If there is no content the string "(no | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | content)" is shown in its place. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | Options to influence the output can be passed as key/value pairs. The | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | following options are recognized: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | =over | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | =item maxlength => $num | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | How much of the content to show. The default is 512. Set this to 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | for unlimited. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | If the content is longer then the string is chopped at the limit and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | the string "...\n(### more bytes not shown)" appended. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | =item no_content => $str | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | Replaces the "(no content)" marker. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | =item prefix => $str | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | A string that will be prefixed to each line of the dump. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | All methods unknown to C<HTTP::Message> itself are delegated to the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | C<HTTP::Headers> object that is part of every message. This allows | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | convenient access to these methods. Refer to L<HTTP::Headers> for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | details of these methods: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | $mess->header( $field => $val ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | $mess->push_header( $field => $val ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | $mess->init_header( $field => $val ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | $mess->remove_header( $field ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | $mess->remove_content_headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | $mess->header_field_names | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | $mess->scan( \&doit ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | $mess->date | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | $mess->expires | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | $mess->if_modified_since | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | $mess->if_unmodified_since | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | $mess->last_modified | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | $mess->content_type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | $mess->content_encoding | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | $mess->content_length | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | $mess->content_language | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | $mess->title | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | $mess->user_agent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | $mess->server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | $mess->from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | $mess->referer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | $mess->www_authenticate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | $mess->authorization | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | $mess->proxy_authorization | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | $mess->authorization_basic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | $mess->proxy_authorization_basic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | Gisle Aas <gisle@activestate.com> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | This software is copyright (c) 1994 by Gisle Aas. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||