line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Archive::Har::Entry; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
18
|
|
5
|
1
|
|
|
1
|
|
5
|
use Carp(); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
6
|
1
|
|
|
1
|
|
570
|
use Archive::Har::Entry::Request(); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
23
|
|
7
|
1
|
|
|
1
|
|
583
|
use Archive::Har::Entry::Response(); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
20
|
|
8
|
1
|
|
|
1
|
|
552
|
use Archive::Har::Entry::Cache(); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
21
|
|
9
|
1
|
|
|
1
|
|
570
|
use Archive::Har::Entry::Timings(); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1513
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.20'; |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
0
|
|
|
sub _DOES_NOT_APPLY { return -1 } |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
0
|
|
|
0
|
1
|
|
my ( $class, $params ) = @_; |
17
|
0
|
|
|
|
|
|
my $self = {}; |
18
|
0
|
|
|
|
|
|
bless $self, $class; |
19
|
0
|
0
|
|
|
|
|
if ( defined $params ) { |
20
|
0
|
0
|
|
|
|
|
if ( defined $params->{pageref} ) { |
21
|
0
|
|
|
|
|
|
$self->pageref( $params->{pageref} ); |
22
|
|
|
|
|
|
|
} |
23
|
0
|
|
|
|
|
|
$self->started_date_time( $params->{startedDateTime} ); |
24
|
|
|
|
|
|
|
$self->request( |
25
|
0
|
|
|
|
|
|
Archive::Har::Entry::Request->new( $params->{request} ) ); |
26
|
|
|
|
|
|
|
$self->response( |
27
|
0
|
|
|
|
|
|
Archive::Har::Entry::Response->new( $params->{response} ) ); |
28
|
0
|
|
|
|
|
|
$self->cache( Archive::Har::Entry::Cache->new( $params->{cache} ) ); |
29
|
|
|
|
|
|
|
$self->timings( |
30
|
0
|
|
|
|
|
|
Archive::Har::Entry::Timings->new( $params->{timings} ) ); |
31
|
0
|
0
|
|
|
|
|
if ( defined $params->{serverIPAddress} ) { |
32
|
0
|
|
|
|
|
|
$self->server_ip_address( $params->{serverIPAddress} ); |
33
|
|
|
|
|
|
|
} |
34
|
0
|
0
|
|
|
|
|
if ( defined $params->{connection} ) { |
35
|
0
|
|
|
|
|
|
$self->connection( $params->{connection} ); |
36
|
|
|
|
|
|
|
} |
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 pageref { |
50
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
51
|
0
|
|
|
|
|
|
my $old = $self->{pageref}; |
52
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
53
|
0
|
|
|
|
|
|
$self->{pageref} = $new; |
54
|
|
|
|
|
|
|
} |
55
|
0
|
|
|
|
|
|
return $old; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub started_date_time { |
59
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
60
|
0
|
|
|
|
|
|
my $old = $self->{startedDateTime}; |
61
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
62
|
0
|
0
|
|
|
|
|
if ( defined $new ) { |
63
|
0
|
|
|
|
|
|
my $date_regex = qr/\d{4}[-]\d{2}[-]\d{2}/smx; |
64
|
0
|
|
|
|
|
|
my $time_regex = qr/\d{2}:\d{2}:\d{2}[.]\d+/smx; |
65
|
0
|
|
|
|
|
|
my $zone_regex = qr/(?:[+]\d{2}:\d{2}|Z)/smx; |
66
|
0
|
0
|
|
|
|
|
if ( $new =~ /^${date_regex}T${time_regex}${zone_regex}$/smx ) { |
67
|
0
|
|
|
|
|
|
$self->{startedDateTime} = $new; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
else { |
70
|
0
|
|
|
|
|
|
Carp::croak('started_date_time is not formatted correctly'); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
else { |
74
|
0
|
|
|
|
|
|
$self->{startedDateTime} = '0000-00-00T00:00:00.0+00:00'; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
0
|
0
|
0
|
|
|
|
if ( ( defined $old ) && ( $old eq '0000-00-00T00:00:00.0+00:00' ) ) { |
78
|
0
|
|
|
|
|
|
return; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
else { |
81
|
0
|
|
|
|
|
|
return $old; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub time { |
86
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
87
|
0
|
|
|
|
|
|
my $timings = $self->timings(); |
88
|
0
|
|
|
|
|
|
my $total = 0; |
89
|
0
|
|
|
|
|
|
my $found = 0; |
90
|
0
|
|
|
|
|
|
foreach my $timing ( |
91
|
|
|
|
|
|
|
$timings->blocked(), $timings->dns(), |
92
|
|
|
|
|
|
|
$timings->connect(), $timings->send(), |
93
|
|
|
|
|
|
|
$timings->wait(), $timings->receive(), |
94
|
|
|
|
|
|
|
$timings->ssl(), |
95
|
|
|
|
|
|
|
) |
96
|
|
|
|
|
|
|
{ |
97
|
0
|
0
|
|
|
|
|
if ( defined $timing ) { |
98
|
0
|
|
|
|
|
|
$found = 1; |
99
|
0
|
|
|
|
|
|
$total += $timing; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
} |
102
|
0
|
0
|
|
|
|
|
if ($found) { |
103
|
0
|
|
|
|
|
|
return $total; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
else { |
106
|
0
|
|
|
|
|
|
return _DOES_NOT_APPLY(); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub request { |
111
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
112
|
0
|
|
|
|
|
|
my $old = $self->{request}; |
113
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
114
|
0
|
|
|
|
|
|
$self->{request} = $new; |
115
|
|
|
|
|
|
|
} |
116
|
0
|
0
|
|
|
|
|
if ( defined $old ) { |
117
|
0
|
|
|
|
|
|
return $old; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
else { |
120
|
0
|
|
|
|
|
|
return Archive::Har::Entry::Request->new(); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub response { |
125
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
126
|
0
|
|
|
|
|
|
my $old = $self->{response}; |
127
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
128
|
0
|
|
|
|
|
|
$self->{response} = $new; |
129
|
|
|
|
|
|
|
} |
130
|
0
|
0
|
|
|
|
|
if ( defined $old ) { |
131
|
0
|
|
|
|
|
|
return $old; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
else { |
134
|
0
|
|
|
|
|
|
return Archive::Har::Entry::Response->new(); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub cache { |
139
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
140
|
0
|
|
|
|
|
|
my $old = $self->{cache}; |
141
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
142
|
0
|
|
|
|
|
|
$self->{cache} = $new; |
143
|
|
|
|
|
|
|
} |
144
|
0
|
0
|
|
|
|
|
if ( defined $old ) { |
145
|
0
|
|
|
|
|
|
return $old; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
else { |
148
|
0
|
|
|
|
|
|
return Archive::Har::Entry::Cache->new(); |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub timings { |
153
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
154
|
0
|
|
|
|
|
|
my $old = $self->{timings}; |
155
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
156
|
0
|
|
|
|
|
|
$self->{timings} = $new; |
157
|
|
|
|
|
|
|
} |
158
|
0
|
0
|
|
|
|
|
if ( defined $old ) { |
159
|
0
|
|
|
|
|
|
return $old; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
else { |
162
|
0
|
|
|
|
|
|
return Archive::Har::Entry::Timings->new(); |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub server_ip_address { |
167
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
168
|
0
|
|
|
|
|
|
my $old = $self->{serverIPAddress}; |
169
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
170
|
0
|
|
|
|
|
|
$self->{serverIPAddress} = $new; |
171
|
|
|
|
|
|
|
} |
172
|
0
|
|
|
|
|
|
return $old; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub connection { |
176
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
177
|
0
|
|
|
|
|
|
my $old = $self->{connection}; |
178
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
179
|
0
|
|
|
|
|
|
$self->{connection} = $new; |
180
|
|
|
|
|
|
|
} |
181
|
0
|
|
|
|
|
|
return $old; |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub comment { |
185
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
186
|
0
|
|
|
|
|
|
my $old = $self->{comment}; |
187
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
188
|
0
|
|
|
|
|
|
$self->{comment} = $new; |
189
|
|
|
|
|
|
|
} |
190
|
0
|
|
|
|
|
|
return $old; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub AUTOLOAD { |
194
|
0
|
|
|
0
|
|
|
my ( $self, $new ) = @_; |
195
|
|
|
|
|
|
|
|
196
|
0
|
|
|
|
|
|
my $name = $Archive::Har::Entry::AUTOLOAD; |
197
|
0
|
|
|
|
|
|
$name =~ s/.*://smx; # strip fully-qualified portion |
198
|
|
|
|
|
|
|
|
199
|
0
|
|
|
|
|
|
my $old; |
200
|
0
|
0
|
|
|
|
|
if ( $name =~ /^_[[:alnum:]]+$/smx ) { # private fields |
|
|
0
|
|
|
|
|
|
201
|
0
|
|
|
|
|
|
$old = $self->{$name}; |
202
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
203
|
0
|
|
|
|
|
|
$self->{$name} = $new; |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
} |
206
|
|
|
|
|
|
|
elsif ( $name eq 'DESTROY' ) { |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
else { |
209
|
0
|
|
|
|
|
|
Carp::croak( |
210
|
|
|
|
|
|
|
"$name is not specified in the HAR 1.2 spec and does not start with an underscore" |
211
|
|
|
|
|
|
|
); |
212
|
|
|
|
|
|
|
} |
213
|
0
|
|
|
|
|
|
return $old; |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
sub TO_JSON { |
217
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
218
|
0
|
|
|
|
|
|
my $json = {}; |
219
|
0
|
0
|
|
|
|
|
if ( defined $self->pageref() ) { |
220
|
0
|
|
|
|
|
|
$json->{pageref} = $self->pageref(); |
221
|
|
|
|
|
|
|
} |
222
|
0
|
0
|
|
|
|
|
if ( defined $self->started_date_time() ) { |
223
|
0
|
|
|
|
|
|
$json->{startedDateTime} = $self->started_date_time(); |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
else { |
226
|
0
|
|
|
|
|
|
$json->{startedDateTime} = '0000-00-00T00:00:00.0+00:00'; |
227
|
|
|
|
|
|
|
} |
228
|
0
|
|
|
|
|
|
$json->{time} = $self->time(); |
229
|
0
|
|
|
|
|
|
$json->{request} = $self->request(); |
230
|
0
|
|
|
|
|
|
$json->{response} = $self->response(); |
231
|
0
|
|
|
|
|
|
$json->{cache} = $self->cache(); |
232
|
0
|
|
|
|
|
|
$json->{timings} = $self->timings(); |
233
|
0
|
0
|
|
|
|
|
if ( defined $self->server_ip_address() ) { |
234
|
0
|
|
|
|
|
|
$json->{serverIPAddress} = $self->server_ip_address(); |
235
|
|
|
|
|
|
|
} |
236
|
0
|
0
|
|
|
|
|
if ( defined $self->connection() ) { |
237
|
0
|
|
|
|
|
|
$json->{connection} = $self->connection(); |
238
|
|
|
|
|
|
|
} |
239
|
0
|
0
|
|
|
|
|
if ( defined $self->comment() ) { |
240
|
0
|
|
|
|
|
|
$json->{comment} = $self->comment(); |
241
|
|
|
|
|
|
|
} |
242
|
0
|
|
|
|
|
|
foreach my $key ( sort { $a cmp $b } keys %{$self} ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
243
|
0
|
0
|
|
|
|
|
next if ( !defined $self->{$key} ); |
244
|
0
|
0
|
|
|
|
|
if ( $key =~ /^_[[:alnum:]]+$/smx ) { # private fields |
245
|
0
|
|
|
|
|
|
$json->{$key} = $self->{$key}; |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
} |
248
|
0
|
|
|
|
|
|
return $json; |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
1; |
252
|
|
|
|
|
|
|
__END__ |