line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Archive::Har::Entry::Request::PostData; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
13
|
|
5
|
1
|
|
|
1
|
|
3
|
use Carp(); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
10
|
|
6
|
1
|
|
|
1
|
|
332
|
use Archive::Har::Entry::Request::PostData::Params(); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
557
|
|
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->mime_type( $params->{mimeType} ); |
16
|
0
|
0
|
0
|
|
|
|
if ( ( defined $params->{params} ) |
|
|
0
|
0
|
|
|
|
|
17
|
|
|
|
|
|
|
&& ( ref $params->{params} eq 'ARRAY' ) |
18
|
0
|
|
|
|
|
|
&& ( scalar @{ $params->{params} } > 0 ) ) |
19
|
|
|
|
|
|
|
{ |
20
|
0
|
|
|
|
|
|
my @params; |
21
|
0
|
|
|
|
|
|
foreach my $param ( @{ $params->{params} } ) { |
|
0
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
push @params, |
23
|
|
|
|
|
|
|
Archive::Har::Entry::Request::PostData::Params->new($param); |
24
|
|
|
|
|
|
|
} |
25
|
0
|
|
|
|
|
|
$self->params( \@params ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
elsif ( defined $params->{text} ) { |
28
|
0
|
|
|
|
|
|
$self->text( $params->{text} ); |
29
|
|
|
|
|
|
|
} |
30
|
0
|
0
|
|
|
|
|
if ( defined $params->{comment} ) { |
31
|
0
|
|
|
|
|
|
$self->comment( $params->{comment} ); |
32
|
|
|
|
|
|
|
} |
33
|
0
|
|
|
|
|
|
foreach my $key ( sort { $a cmp $b } keys %{$params} ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
if ( $key =~ /^_[[:alnum:]]+$/smx ) { # private fields |
35
|
0
|
|
|
|
|
|
$self->$key( $params->{$key} ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
0
|
|
|
|
|
|
return $self; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub mime_type { |
43
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
44
|
0
|
|
|
|
|
|
my $old = $self->{mimeType}; |
45
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
46
|
0
|
|
|
|
|
|
$self->{mimeType} = $new; |
47
|
|
|
|
|
|
|
} |
48
|
0
|
|
|
|
|
|
return $old; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub text { |
52
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
53
|
0
|
|
|
|
|
|
my $old = $self->{text}; |
54
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
55
|
0
|
|
|
|
|
|
delete $self->{params}; |
56
|
0
|
|
|
|
|
|
$self->{text} = $new; |
57
|
|
|
|
|
|
|
} |
58
|
0
|
|
|
|
|
|
return $old; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub params { |
62
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
63
|
0
|
|
|
|
|
|
my $old = $self->{params}; |
64
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
65
|
0
|
|
|
|
|
|
delete $self->{text}; |
66
|
0
|
|
|
|
|
|
$self->{params} = []; |
67
|
0
|
0
|
0
|
|
|
|
if ( ( defined $new ) && ( ref $new eq 'ARRAY' ) ) { |
68
|
0
|
|
|
|
|
|
foreach my $param ( @{$new} ) { |
|
0
|
|
|
|
|
|
|
69
|
0
|
|
|
|
|
|
push @{ $self->{params} }, $param; |
|
0
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
0
|
0
|
|
|
|
|
if ( defined $old ) { |
74
|
0
|
|
|
|
|
|
return @{$old}; |
|
0
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
else { |
77
|
0
|
|
|
|
|
|
return (); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub comment { |
82
|
0
|
|
|
0
|
1
|
|
my ( $self, $new ) = @_; |
83
|
0
|
|
|
|
|
|
my $old = $self->{comment}; |
84
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
85
|
0
|
|
|
|
|
|
$self->{comment} = $new; |
86
|
|
|
|
|
|
|
} |
87
|
0
|
|
|
|
|
|
return $old; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub AUTOLOAD { |
91
|
0
|
|
|
0
|
|
|
my ( $self, $new ) = @_; |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my $name = $Archive::Har::Entry::Request::PostData::AUTOLOAD; |
94
|
0
|
|
|
|
|
|
$name =~ s/.*://smx; # strip fully-qualified portion |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
my $old; |
97
|
0
|
0
|
|
|
|
|
if ( $name =~ /^_[[:alnum:]]+$/smx ) { # private fields |
|
|
0
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
$old = $self->{$name}; |
99
|
0
|
0
|
|
|
|
|
if ( @_ > 1 ) { |
100
|
0
|
|
|
|
|
|
$self->{$name} = $new; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
elsif ( $name eq 'DESTROY' ) { |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
else { |
106
|
0
|
|
|
|
|
|
Carp::croak( |
107
|
|
|
|
|
|
|
"$name is not specified in the HAR 1.2 spec and does not start with an underscore" |
108
|
|
|
|
|
|
|
); |
109
|
|
|
|
|
|
|
} |
110
|
0
|
|
|
|
|
|
return $old; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub TO_JSON { |
114
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
115
|
0
|
|
|
|
|
|
my $json = {}; |
116
|
0
|
|
|
|
|
|
$json->{mimeType} = $self->mime_type(); |
117
|
0
|
|
|
|
|
|
$json->{params} = [ $self->params() ]; |
118
|
0
|
0
|
|
|
|
|
if ( defined $self->text() ) { |
119
|
0
|
|
|
|
|
|
$json->{text} = $self->text(); |
120
|
|
|
|
|
|
|
} |
121
|
0
|
0
|
|
|
|
|
if ( defined $self->comment() ) { |
122
|
0
|
|
|
|
|
|
$json->{comment} = $self->comment(); |
123
|
|
|
|
|
|
|
} |
124
|
0
|
|
|
|
|
|
foreach my $key ( sort { $a cmp $b } keys %{$self} ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
125
|
0
|
0
|
|
|
|
|
next if ( !defined $self->{$key} ); |
126
|
0
|
0
|
|
|
|
|
if ( $key =~ /^_[[:alnum:]]+$/smx ) { # private fields |
127
|
0
|
|
|
|
|
|
$json->{$key} = $self->{$key}; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
} |
130
|
0
|
|
|
|
|
|
return $json; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |
134
|
|
|
|
|
|
|
__END__ |