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

filter: Statementstmt 0.0% 0 / 35 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 54 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.05';
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 && $peer eq $host) {
25 $self->$next($req, $scheme, $host, $port, $peer);
26 }
27 else {
28 my ($ips, $error) = $dns->resolve($host);
29 die "$host: $error\n" if defined $error;
30 die "$host: no IP address found\n" unless @$ips;
31 $self->$next($req, $scheme, $host, $port, $ips->[0]);
32 }
33 };
34  
35 1;
36 __END__