line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
773
|
use 5.010; # _Pulp__5010_qr_m_propagate_properly |
|
1
|
|
|
|
|
3
|
|
2
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
67
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Net::Travis::API::UA::Response; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.002000'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# ABSTRACT: Subclass of HTTP::Tiny::UA::Response for utility methods |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
420
|
use Moo qw( extends has ); |
|
1
|
|
|
|
|
9242
|
|
|
1
|
|
|
|
|
6
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
1
|
|
1477
|
use Encode qw( FB_CROAK ); |
|
1
|
|
|
|
|
6511
|
|
|
1
|
|
|
|
|
449
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
extends 'HTTP::Tiny::UA::Response'; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
has 'json' => ( |
67
|
|
|
|
|
|
|
is => ro =>, |
68
|
|
|
|
|
|
|
lazy => 1, |
69
|
|
|
|
|
|
|
builder => sub { |
70
|
0
|
|
|
0
|
|
|
require JSON::MaybeXS; |
71
|
0
|
|
|
|
|
|
return JSON::MaybeXS->new(); |
72
|
|
|
|
|
|
|
}, |
73
|
|
|
|
|
|
|
); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub content_type { |
88
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
89
|
0
|
0
|
|
|
|
|
return unless exists $self->headers->{'content-type'}; |
90
|
|
|
|
|
|
|
return |
91
|
0
|
0
|
|
|
|
|
unless my ($type) = $self->headers->{'content-type'} =~ qr{ \A ( [^/]+ / [^;]+ ) }msx; |
92
|
0
|
|
|
|
|
|
return $type; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub content_type_params { |
111
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
112
|
0
|
0
|
|
|
|
|
return [] unless exists $self->headers->{'content-type'}; |
113
|
|
|
|
|
|
|
return [] |
114
|
0
|
0
|
|
|
|
|
unless my (@params) = $self->headers->{'content-type'} =~ qr{ (?:;([^;]+))+ }msx; |
115
|
0
|
|
|
|
|
|
return [@params]; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub decoded_content { |
135
|
0
|
|
|
0
|
1
|
|
my ( $self, $force_encoding ) = @_; |
136
|
0
|
0
|
|
|
|
|
if ( not $force_encoding ) { |
137
|
0
|
0
|
|
|
|
|
return $self->content if not my $type = $self->content_type; |
138
|
0
|
0
|
|
|
|
|
return $self->content unless $type =~ qr{ \Atext/ }msx; |
139
|
0
|
|
|
|
|
|
for my $param ( @{ $self->content_type_params } ) { |
|
0
|
|
|
|
|
|
|
140
|
0
|
0
|
|
|
|
|
if ( $param =~ qr{ \Acharset=(.+)\z }msx ) { |
141
|
0
|
|
|
|
|
|
$force_encoding = $param; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
} |
144
|
0
|
0
|
|
|
|
|
return $self->content if not $force_encoding; |
145
|
|
|
|
|
|
|
} |
146
|
0
|
|
|
|
|
|
return Encode::decode( $force_encoding, $self->content, Encode::FB_CROAK ); |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub content_json { |
167
|
0
|
|
|
0
|
1
|
|
my ( $self, $force ) = @_; |
168
|
0
|
|
|
|
|
|
my ($has_force) = ( @_ > 1 ); |
169
|
|
|
|
|
|
|
|
170
|
0
|
|
|
|
|
|
my %whitelist = ( 'application/json' => 1 ); |
171
|
0
|
0
|
0
|
|
|
|
return unless $has_force or exists $whitelist{ $self->content_type }; |
172
|
0
|
|
|
|
|
|
my $charset = 'utf-8'; |
173
|
0
|
0
|
0
|
|
|
|
if ( $has_force and defined $force ) { |
174
|
0
|
|
|
|
|
|
$charset = $force; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
else { |
177
|
0
|
|
|
|
|
|
for my $param ( @{ $self->content_type_params } ) { |
|
0
|
|
|
|
|
|
|
178
|
0
|
0
|
|
|
|
|
next unless $param =~ /\Acharset=(.+)\z/msx; |
179
|
0
|
|
|
|
|
|
$charset = $1; |
180
|
|
|
|
|
|
|
} |
181
|
|
|
|
|
|
|
} |
182
|
0
|
|
|
|
|
|
return $self->json->utf8(0)->decode( $self->decoded_content($charset) ); |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
1
|
|
|
1
|
|
5
|
no Moo; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
1; |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
__END__ |