blib/lib/HTTP/Tiny/Paranoid.pm untested

filter: Statementstmt 0.0% 0 / 37 Branchbran 0.0% 0 / 8 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 55 CC 1 SCAR 6.9
CC
1
Cov
0%
blocked_hosts
2.0
whitelisted_hosts
2.0
BEGIN
2.0
CRAP 2.0
1 package HTTP::Tiny::Paranoid;
2 $HTTP::Tiny::Paranoid::VERSION = '0.07';
3 use strict;
4 use warnings;
5  
6 # ABSTRACT: A safer HTTP::Tiny
7  
8 use HTTP::Tiny 0.070;
9 use parent 'HTTP::Tiny';
10 use Net::DNS::Paranoid;
11 use Class::Method::Modifiers;
12  
13 my $dns = Net::DNS::Paranoid->new;
14  
15 sub blocked_hosts { shift; $dns->blocked_hosts(@_) }
16 sub whitelisted_hosts { shift; $dns->whitelisted_hosts(@_) }
17  
18 around _open_handle => sub {
19 my $next = shift;
20 my $self = shift;
21  
22 my ($req, $scheme, $host, $port, $peer) = @_;
23  
24 if ($peer) {
25 my ($ips, $error) = $dns->resolve($peer);
26 die "$peer: $error\n" if defined $error;
27 $self->$next($req, $scheme, $host, $port, $peer);
28 }
29 else {
30 my ($ips, $error) = $dns->resolve($host);
31 die "$host: $error\n" if defined $error;
32 die "$host: no IP address found\n" unless @$ips;
33 $self->$next($req, $scheme, $host, $port, $ips->[0]);
34 }
35 };
36  
37 1;
38 __END__