line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::RRP::Lite::Response; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
25331
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
1427
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub new { |
6
|
1
|
|
|
1
|
0
|
24
|
my($class, $raw_data) = @_; |
7
|
1
|
|
|
|
|
7
|
my $self = bless { |
8
|
|
|
|
|
|
|
_code => 0, |
9
|
|
|
|
|
|
|
_message => '', |
10
|
|
|
|
|
|
|
_param => {}, |
11
|
|
|
|
|
|
|
}, $class; |
12
|
1
|
|
|
|
|
5
|
$self->_initialize($raw_data); |
13
|
1
|
|
|
|
|
3
|
return $self; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _initialize { |
17
|
1
|
|
|
1
|
|
4
|
my($self, $raw_data) = @_; |
18
|
1
|
|
|
|
|
9
|
my @lines = split(/\r\n/, $raw_data); |
19
|
1
|
|
|
|
|
3
|
my $status_line = shift @lines; |
20
|
1
|
|
|
|
|
8
|
my($code, $message) = $status_line =~ m/^(\d+)\s+(.*)$/; |
21
|
1
|
|
|
|
|
7
|
$self->code($code); |
22
|
1
|
|
|
|
|
6
|
$self->message($message); |
23
|
1
|
|
|
|
|
2
|
my %vars; |
24
|
1
|
|
|
|
|
3
|
for my $line(@lines) { |
25
|
10
|
|
|
|
|
43
|
my($key, $val) = split(/\s*:\s*/, $line, 2); |
26
|
10
|
100
|
|
|
|
34
|
unless ($vars{lc($key)}) { |
|
|
50
|
|
|
|
|
|
27
|
9
|
|
|
|
|
28
|
$vars{lc($key)} = $val |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
elsif (ref($vars{lc($key)}) eq 'ARRAY') { |
30
|
0
|
|
|
|
|
0
|
push @{$vars{lc($key)}}, $val; |
|
0
|
|
|
|
|
0
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
else{ |
33
|
1
|
|
|
|
|
4
|
$vars{lc($key)} = [ $vars{lc($key)} ]; |
34
|
1
|
|
|
|
|
2
|
push @{$vars{lc($key)}}, $val; |
|
1
|
|
|
|
|
5
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
} |
37
|
1
|
|
|
|
|
4
|
$self->{_param} = \%vars; |
38
|
1
|
|
|
|
|
5
|
return $self; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub param { |
42
|
5
|
|
|
5
|
0
|
635
|
my $self = shift; |
43
|
5
|
50
|
|
|
|
20
|
if (@_ == 0) { |
|
|
50
|
|
|
|
|
|
44
|
0
|
|
|
|
|
0
|
return keys %{$self->{_param}}; |
|
0
|
|
|
|
|
0
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
elsif (@_ == 1) { |
47
|
5
|
|
|
|
|
15
|
my $key = lc($_[0]); |
48
|
5
|
|
|
|
|
13
|
$key =~ s/_/ /g; |
49
|
5
|
100
|
|
|
|
23
|
if (ref($self->{_param}->{$key}) eq 'ARRAY') { |
50
|
1
|
50
|
|
|
|
5
|
return wantarray ? @{$self->{_param}->{$key}} : $self->{_param}->{$key}; |
|
1
|
|
|
|
|
7
|
|
51
|
|
|
|
|
|
|
} |
52
|
4
|
|
|
|
|
20
|
return $self->{_param}->{$key}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
else { |
55
|
0
|
|
|
|
|
0
|
$self->{_param}->{$_[0]} = $_[1]; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub code { |
60
|
2
|
|
|
2
|
0
|
7
|
my($self, $code) = @_; |
61
|
2
|
100
|
|
|
|
11
|
$self->{_code} = $code if $code; |
62
|
2
|
|
|
|
|
10
|
return $self->{_code}; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub message { |
66
|
2
|
|
|
2
|
0
|
5
|
my($self, $message) = @_; |
67
|
2
|
100
|
|
|
|
7
|
$self->{_message} = $message if $message; |
68
|
2
|
|
|
|
|
11
|
return $self->{_message}; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |