lib/App/MadEye/Plugin/Agent/HTTP.pm untested

filter: Statementstmt 0.0% 0 / 25 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 40 CC 4 SCAR 24.0
CC
4
Cov
0%
is_dead
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 11.0
1 package App::MadEye::Plugin::Agent::HTTP;
2 use strict;
3 use warnings;
4 use Furl;
5 use App::MadEye::Plugin::Agent::Base;
6  
7 our $TIMEOUT = 15;
8  
9 sub is_dead {
10 my ($self, $url) = @_;
11  
12 my $ua = Furl->new(
13 timeout => $TIMEOUT,
14 agent => $self->config->{config}->{user_agent} || "App::MadEye($App::MadEye::VERSION)",
15 );
16 my $res = $ua->get($url);
17  
18 if ($res->code == 200) {
19 if (my $part = $self->config->{config}->{part}) {
20 if (index($res->content, $part) >= 0) {
21 return; # ok
22 } else {
23 return "contents does not contain $part";
24 }
25 } else {
26 return 0;
27 }
28 } else {
29 return join( "\n", $res->code, $res->message, $res->content );
30 }
31 }
32  
33 1;
34 __END__