line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Archive::Har::Entry::Header; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
43
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
12
|
|
5
|
1
|
|
|
1
|
|
3
|
use Carp(); |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
9
|
|
6
|
1
|
|
|
1
|
|
3
|
use Archive::Har::Entry::Header(); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
436
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.21'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
0
|
|
|
0
|
1
|
|
my ( $class, $params ) = @_; |
12
|
0
|
|
|
|
|
|
my $self = {}; |
13
|
0
|
|
|
|
|
|
bless $self, $class; |
14
|
0
|
0
|
|
|
|
|
if ( defined $params ) { |
15
|
0
|
|
|
|
|
|
$self->name( $params->{name} ); |
16
|
0
|
|
|
|
|
|
$self->value( $params->{value} ); |
17
|
0
|
0
|
|
|
|
|
if ( defined $params->{comment} ) { |
18
|
0
|
|
|
|
|
|
$self->comment( $params->{comment} ); |
19
|
|
|
|
|
|
|
} |
20
|
0
|
|
|
|
|
|
foreach my $key ( sort { $a cmp $b } keys %{$params} ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
21
|
0
|
0
|
|
|
|
|
if ( $key =~ /^_[[:alnum:]]+$/smx ) { # private fields |
22
|
0
|
|
|
|
|
|
$self->$key( $params->{$key} ); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
0
|
|
|
|
|
|
return $self; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub name { |
30
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
31
|
0
|
|
|
|
|
|
my $old = $self->{name}; |
32
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
33
|
0
|
|
|
|
|
|
$self->{name} = $new; |
34
|
|
|
|
|
|
|
} |
35
|
0
|
|
|
|
|
|
return $old; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub value { |
39
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
40
|
0
|
|
|
|
|
|
my $old = $self->{value}; |
41
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
42
|
0
|
|
|
|
|
|
$self->{value} = $new; |
43
|
|
|
|
|
|
|
} |
44
|
0
|
|
|
|
|
|
return $old; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub comment { |
48
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
49
|
0
|
|
|
|
|
|
my $old = $self->{comment}; |
50
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
51
|
0
|
|
|
|
|
|
$self->{comment} = $new; |
52
|
|
|
|
|
|
|
} |
53
|
0
|
|
|
|
|
|
return $old; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub AUTOLOAD { |
57
|
0
|
|
|
0
|
|
|
my ( $self, $new ) = @_; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my $name = $Archive::Har::Entry::Header::AUTOLOAD; |
60
|
0
|
|
|
|
|
|
$name =~ s/.*://smx; # strip fully-qualified portion |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my $old; |
63
|
0
|
0
|
|
|
|
|
if ( $name =~ /^_[[:alnum:]]+$/smx ) { # private fields |
|
|
0
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
$old = $self->{$name}; |
65
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
66
|
0
|
|
|
|
|
|
$self->{$name} = $new; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
elsif ( $name eq 'DESTROY' ) { |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
else { |
72
|
0
|
|
|
|
|
|
Carp::croak( |
73
|
|
|
|
|
|
|
"$name is not specified in the HAR 1.2 spec and does not start with an underscore" |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
} |
76
|
0
|
|
|
|
|
|
return $old; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub TO_JSON { |
80
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
81
|
0
|
|
|
|
|
|
my $json = {}; |
82
|
0
|
|
|
|
|
|
$json->{name} = $self->name(); |
83
|
0
|
|
|
|
|
|
$json->{value} = $self->value(); |
84
|
0
|
0
|
|
|
|
|
if ( defined $self->comment() ) { |
85
|
0
|
|
|
|
|
|
$json->{comment} = $self->comment(); |
86
|
|
|
|
|
|
|
} |
87
|
0
|
|
|
|
|
|
foreach my $key ( sort { $a cmp $b } keys %{$self} ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
88
|
0
|
0
|
|
|
|
|
next if ( !defined $self->{$key} ); |
89
|
0
|
0
|
|
|
|
|
if ( $key =~ /^_[[:alnum:]]+$/smx ) { # private fields |
90
|
0
|
|
|
|
|
|
$json->{$key} = $self->{$key}; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} |
93
|
0
|
|
|
|
|
|
return $json; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
__END__ |