Network/Http.pm

filter: Statementstmt 100% 9 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 12 / 12 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Network/Grep.pm ↑ Summary Network/Icmp.pm »
1 #
2 # $Id$
3 #
4 # network::http Brik
5 #
6 package Metabrik::Network::Http;
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use base qw(Metabrik::Client::Tcp);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 sub brik_properties {
13 return {
14 revision => '$Revision$',
15 tags => [ qw(unstable) ],
16 author => 'GomoR <GomoR[at]metabrik.org>',
17 license => 'http://opensource.org/licenses/BSD-3-Clause',
18 attributes => {
19 host_header => [ qw(host_header) ],
20 },
21 commands => {
22 probe => [ qw(host port|OPTIONAL) ],
23 },
24 require_modules => {
25 'Metabrik::String::Parse' => [ ],
26 },
27 };
28 }
29  
30 sub probe {
31 my $self = shift;
32 my ($host, $port) = @_;
33  
34 $host ||= $self->host;
35 $port ||= 80;
36 $self->brik_help_run_undef_arg('probe', $host) or return;
37  
38 my $probe = "GET / HTTP/1.0\r\n\r\n";
39 if ($self->host_header) {
40 $probe = "GET / HTTP/1.1\r\nHost: ".$self->host_header."\r\n\r\n";
41 }
42  
43 $self->host($host);
44 $self->port($port);
45 $self->connect or return;
46 $self->write($probe) or return;
47 my $response = $self->read or return;
48 $self->disconnect;
49  
50 if (length($response)) {
51 my $sp = Metabrik::String::Parse->new_from_brik_init($self) or return;
52 return $sp->to_array($response);
53 }
54  
55 return $response;
56 }
57  
58 1;
59  
60 __END__
« Network/Grep.pm ↑ Summary Network/Icmp.pm »