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.003'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# ABSTRACT: WAPI Response object |
15
|
|
|
|
|
|
|
# VERSION |
16
|
|
|
|
|
|
|
# AUTHORITY |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
## use critic |
19
|
4
|
|
|
4
|
|
31
|
use strictures 2; |
|
4
|
|
|
|
|
46
|
|
|
4
|
|
|
|
|
202
|
|
20
|
4
|
|
|
4
|
|
1049
|
use Carp qw(croak); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
203
|
|
21
|
4
|
|
|
4
|
|
22
|
use JSON qw(from_json to_json); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
44
|
|
22
|
4
|
|
|
4
|
|
528
|
use Try::Tiny; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
203
|
|
23
|
4
|
|
|
4
|
|
2288
|
use namespace::clean; |
|
4
|
|
|
|
|
57411
|
|
|
4
|
|
|
|
|
25
|
|
24
|
4
|
|
|
4
|
|
3641
|
use Class::Tiny qw( _http_response ); |
|
4
|
|
|
|
|
12856
|
|
|
4
|
|
|
|
|
37
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub BUILD { |
27
|
1211
|
|
|
1211
|
0
|
8385734
|
my $self = shift; |
28
|
1211
|
50
|
|
|
|
38137
|
croak "Missing required attribute" unless defined $self->_http_response; |
29
|
1211
|
50
|
|
|
|
27710
|
croak "Bad attribute" unless ref $self->_http_response eq "HTTP::Response"; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub code { |
33
|
7
|
|
|
7
|
1
|
390
|
return shift->_http_response->{_rc}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub is_success { |
37
|
5
|
|
|
5
|
1
|
1735
|
return shift->_http_response->is_success; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub content { |
41
|
2407
|
|
|
2407
|
1
|
6830
|
my $self = shift; |
42
|
2407
|
|
|
|
|
3769
|
my $h; |
43
|
|
|
|
|
|
|
try { |
44
|
2407
|
|
|
2407
|
|
154619
|
$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
|
|
|
|
|
15775
|
}; |
53
|
2407
|
|
|
|
|
430499
|
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__ |