| 1 | package Archive::Har::Entry::Request; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 10 | ▶ | use Carp(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 10 | ▶ | use Archive::Har::Entry::Header(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 10 | ▶ | use Archive::Har::Entry::Cookie(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 10 | ▶ | use Archive::Har::Entry::Request::QueryString(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 10 | ▶ | use Archive::Har::Entry::Request::PostData(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 10 | our $VERSION = '0.21'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 2132 | ▶ | sub _DOES_NOT_APPLY { return -1 } | ||||||||||||||||||||||||||
|
Subroutine
_DOES_NOT_APPLY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 354 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=15 SCAR=27.3
Pod
documented
| |||||||||||||||||||||||||||||
| 16 | 354 | my ( $class, $params ) = @_; | |||||||||||||||||||||||||||
| 17 | 354 | my $self = {}; | |||||||||||||||||||||||||||
| 18 | 354 | bless $self, $class; | |||||||||||||||||||||||||||
| 19 | 354 | ▶ | if ( defined $params ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 171 | $self->method( $params->{method} ); | |||||||||||||||||||||||||||
| 21 | 171 | $self->url( $params->{url} ); | |||||||||||||||||||||||||||
| 22 | 171 | $self->http_version( $params->{httpVersion} ); | |||||||||||||||||||||||||||
| 23 | 171 | my @cookies; | |||||||||||||||||||||||||||
| 24 | 171 | ▶ | if ( ( defined $params->{cookies} ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $params->{"cookies"} and ref $params->{"cookies"} eq "ARRAY"
MC/DC50%1/2
defined $params->{"cookies"} and ref $params->{"cookies"} eq "ARRAY"
defined $params->{"cookies"}
ref $params->{"cookies"} eq "ARRAY"
Truth table66%2/3
A and B
A= defined $params->{"cookies"}B= ref $params->{"cookies"} eq "ARRAY"
| |||||||||||||||||||||||||||||
| 25 | && ( ref $params->{cookies} eq 'ARRAY' ) ) | ||||||||||||||||||||||||||||
| 26 | { | ||||||||||||||||||||||||||||
| 27 | 170 | foreach my $cookie ( @{ $params->{cookies} } ) { | |||||||||||||||||||||||||||
| 28 | 45 | push @cookies, Archive::Har::Entry::Cookie->new($cookie); | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | 171 | $self->cookies( \@cookies ); | |||||||||||||||||||||||||||
| 32 | 171 | my @headers; | |||||||||||||||||||||||||||
| 33 | 171 | ▶ | if ( ( defined $params->{headers} ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $params->{"headers"} and ref $params->{"headers"} eq "ARRAY"
MC/DC0%0/2
defined $params->{"headers"} and ref $params->{"headers"} eq "ARRAY"
defined $params->{"headers"}
ref $params->{"headers"} eq "ARRAY"
Truth table33%1/3
A and B
A= defined $params->{"headers"}B= ref $params->{"headers"} eq "ARRAY"
| |||||||||||||||||||||||||||||
| 34 | && ( ref $params->{headers} eq 'ARRAY' ) ) | ||||||||||||||||||||||||||||
| 35 | { | ||||||||||||||||||||||||||||
| 36 | 171 | foreach my $header ( @{ $params->{headers} } ) { | |||||||||||||||||||||||||||
| 37 | 1431 | push @headers, Archive::Har::Entry::Header->new($header); | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | 171 | $self->headers( \@headers ); | |||||||||||||||||||||||||||
| 41 | 171 | my @query_string; | |||||||||||||||||||||||||||
| 42 | 171 | ▶ | if ( ( defined $params->{queryString} ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $params->{"queryString"} and ref $params->{"queryString"} eq "ARRAY"
MC/DC0%0/2
defined $params->{"queryString"} and ref $params->{"queryString"} eq "ARRAY"
defined $params->{"queryString"}
ref $params->{"queryString"} eq "ARRAY"
Truth table33%1/3
A and B
A= defined $params->{"queryString"}B= ref $params->{"queryString"} eq "ARRAY"
| |||||||||||||||||||||||||||||
| 43 | && ( ref $params->{queryString} eq 'ARRAY' ) ) | ||||||||||||||||||||||||||||
| 44 | { | ||||||||||||||||||||||||||||
| 45 | 171 | foreach my $query_string ( @{ $params->{queryString} } ) { | |||||||||||||||||||||||||||
| 46 | 178 | push @query_string, | |||||||||||||||||||||||||||
| 47 | Archive::Har::Entry::Request::QueryString->new($query_string); | ||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | 171 | $self->query_string( \@query_string ); | |||||||||||||||||||||||||||
| 51 | 171 | ▶ | if ( defined $params->{postData} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | $self->post_data( | ||||||||||||||||||||||||||||
| 53 | Archive::Har::Entry::Request::PostData->new( | ||||||||||||||||||||||||||||
| 54 | $params->{postData} | ||||||||||||||||||||||||||||
| 55 | ) | ||||||||||||||||||||||||||||
| 56 | 37 | ); | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | 171 | $self->headers_size( $params->{headersSize} ); | |||||||||||||||||||||||||||
| 59 | 171 | $self->body_size( $params->{bodySize} ); | |||||||||||||||||||||||||||
| 60 | 171 | ▶ | if ( defined $params->{comment} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 1 | $self->comment( $params->{comment} ); | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | 171 | foreach my $key ( sort { $a cmp $b } keys %{$params} ) { | |||||||||||||||||||||||||||
| 64 | 1401 | ▶ | if ( $key =~ /^_[[:alnum:]]+$/smx ) { # private fields | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 1 | $self->$key( $params->{$key} ); | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | 354 | return $self; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 667 | ▶ | sub method { | ||||||||||||||||||||||||||
|
Subroutine
method: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 73 | 667 | my ( $self, $new ) = @_; | |||||||||||||||||||||||||||
| 74 | 667 | my $old = $self->{method}; | |||||||||||||||||||||||||||
| 75 | 667 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 76 | 176 | ▶ | $self->{method} = defined $new ? uc $new : $new; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | 667 | ▶ | if ( defined $old ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 459 | return $old; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | else { | ||||||||||||||||||||||||||||
| 82 | 208 | return 'GET'; | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 666 | ▶ | sub url { | ||||||||||||||||||||||||||
|
Subroutine
url: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 87 | 666 | my ( $self, $new ) = @_; | |||||||||||||||||||||||||||
| 88 | 666 | my $old = $self->{url}; | |||||||||||||||||||||||||||
| 89 | 666 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 176 | $self->{url} = $new; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | 666 | ▶ | if ( defined $old ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 458 | return $old; | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | else { | ||||||||||||||||||||||||||||
| 96 | 208 | return 'http://example.com/'; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 666 | ▶ | sub http_version { | ||||||||||||||||||||||||||
|
Subroutine
http_version: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 101 | 666 | my ( $self, $new ) = @_; | |||||||||||||||||||||||||||
| 102 | 666 | my $old = $self->{httpVersion}; | |||||||||||||||||||||||||||
| 103 | 666 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 104 | 176 | ▶ | $self->{httpVersion} = defined $new ? uc $new : $new; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | 666 | ▶ | if ( defined $old ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 107 | 458 | return $old; | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | else { | ||||||||||||||||||||||||||||
| 110 | 208 | return 'HTTP/0.9'; | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 670 | ▶ | sub cookies { | ||||||||||||||||||||||||||
|
Subroutine
cookies: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 115 | 670 | my ( $self, $new ) = @_; | |||||||||||||||||||||||||||
| 116 | 670 | my $old = $self->{cookies}; | |||||||||||||||||||||||||||
| 117 | 670 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | 176 | $self->{cookies} = $new; | |||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | 670 | ▶ | if ( ( defined $old ) && ( ref $old eq 'ARRAY' ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $old and ref $old eq "ARRAY"
MC/DC50%1/2
defined $old and ref $old eq "ARRAY"
defined $old
ref $old eq "ARRAY"
Truth table66%2/3
A and B
A= defined $oldB= ref $old eq "ARRAY"
| |||||||||||||||||||||||||||||
| 121 | 484 | return @{$old}; | |||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | else { | ||||||||||||||||||||||||||||
| 124 | 186 | return (); | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | 672 | ▶ | sub headers { | ||||||||||||||||||||||||||
|
Subroutine
headers: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 129 | 672 | my ( $self, $new ) = @_; | |||||||||||||||||||||||||||
| 130 | 672 | my $old = $self->{headers}; | |||||||||||||||||||||||||||
| 131 | 672 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | 176 | $self->{headers} = $new; | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | 672 | ▶ | if ( ( defined $old ) && ( ref $old eq 'ARRAY' ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $old and ref $old eq "ARRAY"
MC/DC50%1/2
defined $old and ref $old eq "ARRAY"
defined $old
ref $old eq "ARRAY"
Truth table66%2/3
A and B
A= defined $oldB= ref $old eq "ARRAY"
| |||||||||||||||||||||||||||||
| 135 | 486 | return @{$old}; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | else { | ||||||||||||||||||||||||||||
| 138 | 186 | return (); | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 670 | ▶ | sub query_string { | ||||||||||||||||||||||||||
|
Subroutine
query_string: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 143 | 670 | my ( $self, $new ) = @_; | |||||||||||||||||||||||||||
| 144 | 670 | my $old = $self->{queryString}; | |||||||||||||||||||||||||||
| 145 | 670 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 176 | $self->{queryString} = $new; | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | 670 | ▶ | if ( ( defined $old ) && ( ref $old eq 'ARRAY' ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $old and ref $old eq "ARRAY"
MC/DC50%1/2
defined $old and ref $old eq "ARRAY"
defined $old
ref $old eq "ARRAY"
Truth table66%2/3
A and B
A= defined $oldB= ref $old eq "ARRAY"
| |||||||||||||||||||||||||||||
| 149 | 484 | return @{$old}; | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | else { | ||||||||||||||||||||||||||||
| 152 | 186 | return (); | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 603 | ▶ | sub post_data { | ||||||||||||||||||||||||||
|
Subroutine
post_data: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 157 | 603 | my ( $self, $new ) = @_; | |||||||||||||||||||||||||||
| 158 | 603 | my $old = $self->{postData}; | |||||||||||||||||||||||||||
| 159 | 603 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | 38 | $self->{postData} = $new; | |||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | 603 | return $old; | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 1111 | ▶ | sub headers_size { | ||||||||||||||||||||||||||
|
Subroutine
headers_size: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 166 | 1111 | my ( $self, $new ) = @_; | |||||||||||||||||||||||||||
| 167 | 1111 | my $old = $self->{headersSize}; | |||||||||||||||||||||||||||
| 168 | 1111 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | 181 | ▶ | if ( ( defined $new ) && ( $new =~ /^(\d+)$/smx ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $new and $new =~ /^(\d+)$/msx
MC/DC100%2/2
defined $new and $new =~ /^(\d+)$/msx
defined $new
$new =~ /^(\d+)$/msx
Truth table100%3/3
A and B
A= defined $newB= $new =~ /^(\d+)$/msx
| |||||||||||||||||||||||||||||
| 170 | 162 | $self->{headersSize} = $1 + 0; | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | else { | ||||||||||||||||||||||||||||
| 173 | 19 | $self->{headersSize} = _DOES_NOT_APPLY(); | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | 1111 | ▶ | if ( ( defined $old ) && ( $old == _DOES_NOT_APPLY() ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $old and $old == _DOES_NOT_APPLY()
MC/DC100%2/2
defined $old and $old == _DOES_NOT_APPLY()
defined $old
$old == _DOES_NOT_APPLY()
Truth table100%3/3
A and B
A= defined $oldB= $old == _DOES_NOT_APPLY()
| |||||||||||||||||||||||||||||
| 177 | 41 | return; | |||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||
| 179 | else { | ||||||||||||||||||||||||||||
| 180 | 1070 | return $old; | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 791 | ▶ | sub body_size { | ||||||||||||||||||||||||||
|
Subroutine
body_size: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 185 | 791 | my ( $self, $new ) = @_; | |||||||||||||||||||||||||||
| 186 | 791 | my $old = $self->{bodySize}; | |||||||||||||||||||||||||||
| 187 | 791 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 188 | 176 | ▶ | if ( ( defined $new ) && ( $new =~ /^(\d+)$/smx ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $new and $new =~ /^(\d+)$/msx
MC/DC100%2/2
defined $new and $new =~ /^(\d+)$/msx
defined $new
$new =~ /^(\d+)$/msx
Truth table100%3/3
A and B
A= defined $newB= $new =~ /^(\d+)$/msx
| |||||||||||||||||||||||||||||
| 189 | 68 | $self->{bodySize} = $1 + 0; | |||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||
| 191 | else { | ||||||||||||||||||||||||||||
| 192 | 108 | $self->{bodySize} = _DOES_NOT_APPLY(); | |||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | 791 | ▶ | if ( ( defined $old ) && ( $old == _DOES_NOT_APPLY() ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $old and $old == _DOES_NOT_APPLY()
MC/DC100%2/2
defined $old and $old == _DOES_NOT_APPLY()
defined $old
$old == _DOES_NOT_APPLY()
Truth table100%3/3
A and B
A= defined $oldB= $old == _DOES_NOT_APPLY()
| |||||||||||||||||||||||||||||
| 196 | 418 | return; | |||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||
| 198 | else { | ||||||||||||||||||||||||||||
| 199 | 373 | return $old; | |||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 512 | ▶ | sub comment { | ||||||||||||||||||||||||||
|
Subroutine
comment: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 204 | 512 | my ( $self, $new ) = @_; | |||||||||||||||||||||||||||
| 205 | 512 | my $old = $self->{comment}; | |||||||||||||||||||||||||||
| 206 | 512 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 207 | 1 | $self->{comment} = $new; | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | 512 | return $old; | |||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 357 | ▶ | sub AUTOLOAD { | ||||||||||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 213 | 357 | my ( $self, $new ) = @_; | |||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 357 | my $name = $Archive::Har::Entry::Request::AUTOLOAD; | |||||||||||||||||||||||||||
| 216 | 357 | $name =~ s/.*://smx; # strip fully-qualified portion | |||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 357 | my $old; | |||||||||||||||||||||||||||
| 219 | 357 | ▶ | if ( $name =~ /^_[[:alnum:]]+$/smx ) { # private fields | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 220 | 4 | $old = $self->{$name}; | |||||||||||||||||||||||||||
| 221 | 4 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 222 | 3 | $self->{$name} = $new; | |||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | elsif ( $name eq 'DESTROY' ) { | ||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | else { | ||||||||||||||||||||||||||||
| 228 | 1 | Carp::croak( | |||||||||||||||||||||||||||
| 229 | "$name is not specified in the HAR 1.2 spec and does not start with an underscore" | ||||||||||||||||||||||||||||
| 230 | ); | ||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | 356 | return $old; | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 489 | ▶ | sub TO_JSON { | ||||||||||||||||||||||||||
|
Subroutine
TO_JSON: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 236 | 489 | my ($self) = @_; | |||||||||||||||||||||||||||
| 237 | 489 | my $json = {}; | |||||||||||||||||||||||||||
| 238 | 489 | $json->{method} = $self->method(); | |||||||||||||||||||||||||||
| 239 | 489 | $json->{url} = $self->url(); | |||||||||||||||||||||||||||
| 240 | 489 | $json->{httpVersion} = $self->http_version(); | |||||||||||||||||||||||||||
| 241 | 489 | $json->{cookies} = [ $self->cookies() ]; | |||||||||||||||||||||||||||
| 242 | 489 | $json->{headers} = [ $self->headers() ]; | |||||||||||||||||||||||||||
| 243 | 489 | $json->{queryString} = [ $self->query_string() ]; | |||||||||||||||||||||||||||
| 244 | 489 | ▶ | if ( defined $self->post_data() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 245 | 61 | $json->{postData} = $self->post_data(); | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | 489 | ▶ | if ( defined $self->body_size() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | 62 | $json->{bodySize} = $self->body_size(); | |||||||||||||||||||||||||||
| 249 | 62 | ▶ | if ( $self->body_size() == 0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 250 | 54 | delete $json->{postData}; | |||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | else { | ||||||||||||||||||||||||||||
| 254 | 427 | $json->{bodySize} = _DOES_NOT_APPLY(); | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | 489 | ▶ | if ( defined $self->headers_size() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 257 | 441 | $json->{headersSize} = $self->headers_size(); | |||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||
| 259 | else { | ||||||||||||||||||||||||||||
| 260 | 48 | $json->{headersSize} = _DOES_NOT_APPLY(); | |||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | 489 | ▶ | if ( defined $self->comment() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 263 | 22 | $json->{comment} = $self->comment(); | |||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||
| 265 | 489 | foreach my $key ( sort { $a cmp $b } keys %{$self} ) { | |||||||||||||||||||||||||||
| 266 | 3937 | ▶ | next if ( !defined $self->{$key} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 267 | 3870 | ▶ | if ( $key =~ /^_[[:alnum:]]+$/smx ) { # private fields | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 268 | 21 | $json->{$key} = $self->{$key}; | |||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | 489 | return $json; | |||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | 10 | 1; | |||||||||||||||||||||||||||
| 275 | __END__ | ||||||||||||||||||||||||||||