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

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 4 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 43 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.04';
3 use strict;
4 use warnings;
5  
6 # ABSTRACT: A safer HTTP::Tiny
7  
8 use parent 'HTTP::Tiny';
9 use Net::DNS::Paranoid;
10 use Class::Method::Modifiers;
11  
12 my $dns = Net::DNS::Paranoid->new;
13  
14 sub blocked_hosts { shift; $dns->blocked_hosts(@_) }
15 sub whitelisted_hosts { shift; $dns->whitelisted_hosts(@_) }
16  
17 around _open_handle => sub {
18 my $next = shift;
19 my $self = shift;
20  
21 my ($req, $scheme, $host, $port) = @_;
22 my ($ips, $error) = $dns->resolve($host);
23 die "$host: $error\n" if defined $error;
24 die "$host: no IP address found\n" unless @$ips;
25  
26 $self->$next($req, $scheme, $ips->[0], $port);
27 };
28  
29 1;
30 __END__