line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Archive::Har::Entry::Response; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
4
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
14
|
|
5
|
1
|
|
|
1
|
|
4
|
use Carp(); |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
10
|
|
6
|
1
|
|
|
1
|
|
2
|
use Archive::Har::Entry::Header(); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
7
|
1
|
|
|
1
|
|
3
|
use Archive::Har::Entry::Cookie(); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
12
|
|
8
|
1
|
|
|
1
|
|
336
|
use Archive::Har::Entry::Response::Content(); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
899
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.21'; |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
|
0
|
|
|
sub _DOES_NOT_APPLY { return -1 } |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
0
|
|
|
0
|
1
|
|
my ( $class, $params ) = @_; |
16
|
0
|
|
|
|
|
|
my $self = {}; |
17
|
0
|
|
|
|
|
|
bless $self, $class; |
18
|
0
|
0
|
|
|
|
|
if ( defined $params ) { |
19
|
0
|
|
|
|
|
|
$self->status( $params->{status} ); |
20
|
0
|
|
|
|
|
|
$self->status_text( $params->{statusText} ); |
21
|
0
|
|
|
|
|
|
$self->http_version( $params->{httpVersion} ); |
22
|
0
|
|
|
|
|
|
my @cookies; |
23
|
0
|
|
|
|
|
|
foreach my $cookie ( @{ $params->{cookies} } ) { |
|
0
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
push @cookies, Archive::Har::Entry::Cookie->new($cookie); |
25
|
|
|
|
|
|
|
} |
26
|
0
|
|
|
|
|
|
$self->cookies( \@cookies ); |
27
|
0
|
|
|
|
|
|
my @headers; |
28
|
0
|
|
|
|
|
|
foreach my $header ( @{ $params->{headers} } ) { |
|
0
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
push @headers, Archive::Har::Entry::Header->new($header); |
30
|
|
|
|
|
|
|
} |
31
|
0
|
|
|
|
|
|
$self->headers( \@headers ); |
32
|
|
|
|
|
|
|
$self->content( |
33
|
0
|
|
|
|
|
|
Archive::Har::Entry::Response::Content->new( $params->{content} ) ); |
34
|
0
|
|
|
|
|
|
$self->redirect_url( $params->{redirectURL} ); |
35
|
0
|
|
|
|
|
|
$self->headers_size( $params->{headersSize} ); |
36
|
0
|
|
|
|
|
|
$self->body_size( $params->{bodySize} ); |
37
|
0
|
0
|
|
|
|
|
if ( defined $params->{comment} ) { |
38
|
0
|
|
|
|
|
|
$self->comment( $params->{comment} ); |
39
|
|
|
|
|
|
|
} |
40
|
0
|
|
|
|
|
|
foreach my $key ( sort { $a cmp $b } keys %{$params} ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
if ( $key =~ /^_[[:alnum:]]+$/smx ) { # private fields |
42
|
0
|
|
|
|
|
|
$self->$key( $params->{$key} ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
0
|
|
|
|
|
|
return $self; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub status { |
50
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
51
|
0
|
|
|
|
|
|
my $old = $self->{status}; |
52
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
53
|
0
|
|
|
|
|
|
$self->{status} = $new; |
54
|
|
|
|
|
|
|
} |
55
|
0
|
0
|
|
|
|
|
if ( defined $old ) { |
56
|
0
|
|
|
|
|
|
return $old; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
else { |
59
|
0
|
|
|
|
|
|
return 0; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub status_text { |
64
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
65
|
0
|
|
|
|
|
|
my $old = $self->{statusText}; |
66
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
67
|
0
|
|
|
|
|
|
$self->{statusText} = $new; |
68
|
|
|
|
|
|
|
} |
69
|
0
|
0
|
|
|
|
|
if ( defined $old ) { |
70
|
0
|
|
|
|
|
|
return $old; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
else { |
73
|
0
|
|
|
|
|
|
return 'Unknown'; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub http_version { |
78
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
79
|
0
|
|
|
|
|
|
my $old = $self->{httpVersion}; |
80
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
81
|
0
|
|
|
|
|
|
$self->{httpVersion} = $new; |
82
|
|
|
|
|
|
|
} |
83
|
0
|
0
|
|
|
|
|
if ( defined $old ) { |
84
|
0
|
|
|
|
|
|
return $old; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
else { |
87
|
0
|
|
|
|
|
|
return 'Unknown'; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub headers { |
92
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
93
|
0
|
|
|
|
|
|
my $old = $self->{headers}; |
94
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
95
|
0
|
|
|
|
|
|
$self->{headers} = $new; |
96
|
|
|
|
|
|
|
} |
97
|
0
|
0
|
|
|
|
|
if ( defined $old ) { |
98
|
0
|
|
|
|
|
|
return @{$old}; |
|
0
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
else { |
101
|
0
|
|
|
|
|
|
return (); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub cookies { |
106
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
107
|
0
|
|
|
|
|
|
my $old = $self->{cookies}; |
108
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
109
|
0
|
|
|
|
|
|
$self->{cookies} = $new; |
110
|
|
|
|
|
|
|
} |
111
|
0
|
0
|
|
|
|
|
if ( defined $old ) { |
112
|
0
|
|
|
|
|
|
return @{$old}; |
|
0
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
else { |
115
|
0
|
|
|
|
|
|
return (); |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub content { |
120
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
121
|
0
|
|
|
|
|
|
my $old = $self->{content}; |
122
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
123
|
0
|
|
|
|
|
|
$self->{content} = Archive::Har::Entry::Response::Content->new($new); |
124
|
|
|
|
|
|
|
} |
125
|
0
|
|
|
|
|
|
return $old; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub redirect_url { |
129
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
130
|
0
|
|
|
|
|
|
my $old = $self->{redirectURL}; |
131
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
132
|
0
|
|
|
|
|
|
$self->{redirectURL} = $new; |
133
|
|
|
|
|
|
|
} |
134
|
0
|
|
|
|
|
|
return $old; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub headers_size { |
138
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
139
|
0
|
|
|
|
|
|
my $old = $self->{headersSize}; |
140
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
141
|
0
|
0
|
|
|
|
|
if ( defined $new ) { |
142
|
0
|
|
|
|
|
|
$self->{headersSize} = $new + 0; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
else { |
145
|
0
|
|
|
|
|
|
$self->{headersSize} = _DOES_NOT_APPLY(); |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
} |
148
|
0
|
0
|
0
|
|
|
|
if ( ( defined $old ) && ( $old == _DOES_NOT_APPLY() ) ) { |
149
|
0
|
|
|
|
|
|
return; |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
else { |
152
|
0
|
|
|
|
|
|
return $old; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
sub body_size { |
157
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
158
|
0
|
|
|
|
|
|
my $old = $self->{bodySize}; |
159
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
160
|
0
|
0
|
|
|
|
|
if ( defined $new ) { |
161
|
0
|
|
|
|
|
|
$self->{bodySize} = $new + 0; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
else { |
164
|
0
|
|
|
|
|
|
$self->{bodySize} = _DOES_NOT_APPLY(); |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
} |
167
|
0
|
0
|
0
|
|
|
|
if ( ( defined $old ) && ( $old == _DOES_NOT_APPLY() ) ) { |
168
|
0
|
|
|
|
|
|
return; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
else { |
171
|
0
|
|
|
|
|
|
return $old; |
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub comment { |
176
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
177
|
0
|
|
|
|
|
|
my $old = $self->{comment}; |
178
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
179
|
0
|
|
|
|
|
|
$self->{comment} = $new; |
180
|
|
|
|
|
|
|
} |
181
|
0
|
|
|
|
|
|
return $old; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub AUTOLOAD { |
185
|
0
|
|
|
0
|
|
|
my ( $self, $new ) = @_; |
186
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
|
my $name = $Archive::Har::Entry::Response::AUTOLOAD; |
188
|
0
|
|
|
|
|
|
$name =~ s/.*://smx; # strip fully-qualified portion |
189
|
|
|
|
|
|
|
|
190
|
0
|
|
|
|
|
|
my $old; |
191
|
0
|
0
|
|
|
|
|
if ( $name =~ /^_[[:alnum:]]+$/smx ) { # private fields |
|
|
0
|
|
|
|
|
|
192
|
0
|
|
|
|
|
|
$old = $self->{$name}; |
193
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
194
|
0
|
|
|
|
|
|
$self->{$name} = $new; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
elsif ( $name eq 'DESTROY' ) { |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
else { |
200
|
0
|
|
|
|
|
|
Carp::croak( |
201
|
|
|
|
|
|
|
"$name is not specified in the HAR 1.2 spec and does not start with an underscore" |
202
|
|
|
|
|
|
|
); |
203
|
|
|
|
|
|
|
} |
204
|
0
|
|
|
|
|
|
return $old; |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
sub TO_JSON { |
208
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
209
|
0
|
|
|
|
|
|
my $json = {}; |
210
|
0
|
|
|
|
|
|
$json->{status} = $self->status(); |
211
|
0
|
|
|
|
|
|
$json->{statusText} = $self->status_text(); |
212
|
0
|
|
|
|
|
|
$json->{httpVersion} = $self->http_version(); |
213
|
0
|
|
|
|
|
|
$json->{cookies} = [ $self->cookies() ]; |
214
|
0
|
|
|
|
|
|
$json->{headers} = [ $self->headers() ]; |
215
|
0
|
|
|
|
|
|
$json->{content} = $self->content(); |
216
|
0
|
|
|
|
|
|
$json->{redirectURL} = $self->redirect_url(); |
217
|
0
|
0
|
|
|
|
|
if ( defined $self->headers_size() ) { |
218
|
0
|
|
|
|
|
|
$json->{headersSize} = $self->headers_size(); |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
else { |
221
|
0
|
|
|
|
|
|
$json->{headersSize} = _DOES_NOT_APPLY(); |
222
|
|
|
|
|
|
|
} |
223
|
0
|
|
|
|
|
|
$json->{headersSize} += 0; |
224
|
0
|
0
|
|
|
|
|
if ( defined $self->body_size() ) { |
225
|
0
|
|
|
|
|
|
$json->{bodySize} = $self->body_size(); |
226
|
|
|
|
|
|
|
} |
227
|
|
|
|
|
|
|
else { |
228
|
0
|
|
|
|
|
|
$json->{bodySize} = _DOES_NOT_APPLY(); |
229
|
|
|
|
|
|
|
} |
230
|
0
|
|
|
|
|
|
$json->{bodySize} += 0; |
231
|
0
|
0
|
|
|
|
|
if ( defined $self->comment() ) { |
232
|
0
|
|
|
|
|
|
$json->{comment} = $self->comment(); |
233
|
|
|
|
|
|
|
} |
234
|
0
|
|
|
|
|
|
foreach my $key ( sort { $a cmp $b } keys %{$self} ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
235
|
0
|
0
|
|
|
|
|
next if ( !defined $self->{$key} ); |
236
|
0
|
0
|
|
|
|
|
if ( $key =~ /^_[[:alnum:]]+$/smx ) { # private fields |
237
|
0
|
|
|
|
|
|
$json->{$key} = $self->{$key}; |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
} |
240
|
0
|
|
|
|
|
|
return $json; |
241
|
|
|
|
|
|
|
} |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
1; |
244
|
|
|
|
|
|
|
__END__ |