line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of DNS-NIOS |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2021 by Christian Segundo. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The Artistic License 2.0 (GPL Compatible) |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
## no critic |
11
|
|
|
|
|
|
|
package DNS::NIOS::Response; |
12
|
|
|
|
|
|
|
$DNS::NIOS::Response::VERSION = '0.005'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# ABSTRACT: WAPI Response object |
15
|
|
|
|
|
|
|
# VERSION |
16
|
|
|
|
|
|
|
# AUTHORITY |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
## use critic |
19
|
4
|
|
|
4
|
|
30
|
use strictures 2; |
|
4
|
|
|
|
|
36
|
|
|
4
|
|
|
|
|
186
|
|
20
|
4
|
|
|
4
|
|
978
|
use Carp qw(croak); |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
217
|
|
21
|
4
|
|
|
4
|
|
22
|
use JSON qw(from_json to_json); |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
31
|
|
22
|
4
|
|
|
4
|
|
505
|
use Try::Tiny; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
243
|
|
23
|
4
|
|
|
4
|
|
2263
|
use namespace::clean; |
|
4
|
|
|
|
|
56693
|
|
|
4
|
|
|
|
|
29
|
|
24
|
4
|
|
|
4
|
|
3521
|
use Class::Tiny qw( _http_response ); |
|
4
|
|
|
|
|
12886
|
|
|
4
|
|
|
|
|
35
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub BUILD { |
27
|
1211
|
|
|
1211
|
0
|
8269927
|
my $self = shift; |
28
|
1211
|
50
|
|
|
|
36918
|
croak "Missing required attribute" unless defined $self->_http_response; |
29
|
1211
|
50
|
|
|
|
27188
|
croak "Bad attribute" unless ref $self->_http_response eq "HTTP::Response"; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub code { |
33
|
7
|
|
|
7
|
1
|
434
|
return shift->_http_response->{_rc}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub is_success { |
37
|
5
|
|
|
5
|
1
|
1643
|
return shift->_http_response->is_success; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub content { |
41
|
2407
|
|
|
2407
|
1
|
7042
|
my $self = shift; |
42
|
2407
|
|
|
|
|
3923
|
my $h; |
43
|
|
|
|
|
|
|
try { |
44
|
2407
|
|
|
2407
|
|
153624
|
$h = from_json( $self->_http_response->decoded_content ); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
catch { |
48
|
0
|
|
|
0
|
|
0
|
$h = $self->_http_response->decoded_content; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# For some reason <5.28 returns a quoted string during test |
51
|
0
|
|
|
|
|
0
|
$h =~ s/^"|"$//g; |
52
|
2407
|
|
|
|
|
16432
|
}; |
53
|
2407
|
|
|
|
|
436311
|
return $h; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub json { |
57
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
58
|
|
|
|
|
|
|
try { |
59
|
0
|
|
|
0
|
|
|
my $h = to_json( $self->content, @_ ); |
60
|
0
|
|
|
|
|
|
return $h; |
61
|
0
|
|
|
|
|
|
}; |
62
|
0
|
|
|
|
|
|
return to_json( { content => $self->content }, @_ ); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub pretty { |
66
|
0
|
|
|
0
|
1
|
|
return shift->json( { utf8 => 1, pretty => 1 } ); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |