blib/lib/ASNMTAP/Asnmtap/Plugins/WebTransact.pm

filter: Statementstmt 39.2% 198 / 504 Branchbran 19.0% 48 / 252 Conditioncond 20.0% 12 / 60 MC/DCmcdc 2.6% 1 / 38 Subroutinesub 75.8% 22 / 29 Podpod 100% 2 / 2 totaltotal 31.9% 283 / 885 CC 155 SCAR 75.9
CC
155
Cov
32%
check
3588.0
_my_match
110.0
new
81.9
CRAP 1980.4
« blib/lib/ASNMTAP/Asnmtap/Plugins/Modem.pm ↑ Summary blib/lib/ASNMTAP/Asnmtap/Applications/CGI.pm »
1 # ----------------------------------------------------------------------------------------------------------
2 # © Copyright 2003-2011 by Alex Peeters [alex.peeters@citap.be]
3 # ----------------------------------------------------------------------------------------------------------
4 # 2011/mm/dd, v3.002.003, package ASNMTAP::Asnmtap::Plugins::WebTransact
5 # ----------------------------------------------------------------------------------------------------------
6  
7 package ASNMTAP::Asnmtap::Plugins::WebTransact;
8  
9 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
10  
11 25 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 25 ▶use warnings; # Must be used in test mode only. This reduces a little process speed
Subroutine BEGIN: called CC=1 SCAR=0.0
13 #use diagnostics; # Must be used in test mode only. This reduces a lot of process speed
14  
15 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
16  
17 25 ▶use CGI::Carp qw(fatalsToBrowser set_message cluck);
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 25 ▶use HTTP::Request::Common qw(GET POST HEAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
20 25 ▶use HTTP::Cookies;
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 25 ▶use LWP::Debug;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 25 ▶use LWP::UserAgent;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
26  
27 25 ▶use ASNMTAP::Asnmtap qw(%ERRORS %TYPE &_dumpValue);
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
30  
31 25 ▶BEGIN { $ASNMTAP::Asnmtap::Plugins::WebTransact::VERSION = do { my @r = (q$Revision: 3.002.003$ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r }; }
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
34  
35 25 ▶use constant FALSE => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 25 ▶use constant TRUE => ! FALSE;
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 25 ▶use constant Field_Refs => {
Subroutine BEGIN: called CC=1 SCAR=0.0
39 Method => { is_ref => FALSE, type => '' },
40 Url => { is_ref => FALSE, type => '' },
41 Qs_var => { is_ref => TRUE, type => 'ARRAY' },
42 Qs_fixed => { is_ref => TRUE, type => 'ARRAY' },
43 Exp => { is_ref => FALSE, type => 'ARRAY' },
44 Exp_Fault => { is_ref => FALSE, type => '' },
45 Exp_Return => { is_ref => TRUE, type => 'HASH' },
46 Msg => { is_ref => FALSE, type => '' },
47 Msg_Fault => { is_ref => FALSE, type => '' },
48 Timeout => { is_ref => FALSE, type => undef },
49 Perfdata_Label => { is_ref => FALSE, type => undef }
50 25 };
51  
52 25 my (%returns, %downloaded, $ua);
53 25 keys %downloaded = 128;
54  
55 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
56  
57 0 ▶sub _handleHttpdErrors { print "<hr><h1>ASNMTAP::Asnmtap::Plugins::WebTransact It's not a bug, it's a feature!</h1><p>Error: $_[0]</p><hr>"; }
Subroutine _handleHttpdErrors: not called CC=1 SCAR=6.9
58  
59 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
60  
61 25 set_message ( \&_handleHttpdErrors );
62  
63 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
64  
65 9 ▶sub _error_message { $_[0] =~ s/\n/ /g; $_[0]; }
Subroutine _error_message: called CC=1 SCAR=0.0
66  
67 # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
68  
69 6 ▶sub new {
Subroutine new: called CC=19 SCAR=44.1
Pod documented
70 6 my ($object, $asnmtapInherited, $urls_ar) = @_;
71  
72 # $urls_ar is a ref to a list of hashes (representing a request record) in a partic format.
73  
74 # If a hash is __not__ in that format it's much better to cluck since it is
75 # hard to interpret 'not an array ref' messages (from check::_make_request) caused
76 # by mis spelled or mistaken field names.
77  
78 6 ▶ &_dumpValue ( $asnmtapInherited, $object .': attribute asnmtapInherited is missing.' ) unless ( defined $asnmtapInherited );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $asnmtapInherited 0 6 6
79  
80 6 ▶ &_dumpValue ( $urls_ar, $object .': URL list is not an array reference.' ) if ( ref $urls_ar ne 'ARRAY' );
Branch: 1 branch
BranchTrueFalseTotal
if ref $urls_ar ne "ARRAY" 0 6 6
81 6 my @urls = @$urls_ar;
82  
83 6 foreach my $url ( @urls ) {
84 0 ▶ &_dumpValue ( $url, $object .': Request record is not a hash.' ) if ( ref $url ne 'HASH' );
Branch: 1 branch
BranchTrueFalseTotal
if ref $url ne "HASH" 0 0 0
85 0 my @keys = keys %$url;
86  
87 0 foreach my $key ( @keys ) {
88 0 ▶ unless ( exists Field_Refs->{$key} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists {"Exp" => {"is_ref" => 0,"type" => "ARRAY"},"Exp_Fault" => {"is_ref" => 0,"type" => ""},"Exp_Return" => {"is_ref" => !!1,"type" => "HASH"},"Method" => {"is_ref" => 0,"type" => ""},"Msg" => {"is_ref" => 0,"type" => ""},"Msg_Fault" => {"is_ref" => 0,"type" => ""},"Perfdata_Label" => {"is_ref" => 0,"type" => undef},"Qs_fixed" => {"is_ref" => !!1,"type" => "ARRAY"},"Qs_var" => {"is_ref" => !!1,"type" => "ARRAY"},"Timeout" => {"is_ref" => 0,"type" => undef},"Url" => {"is_ref" => 0,"type" => ""}}->{$key}) 0 0 0
89 0 warn "Expected keys: ", join " ", keys %{ (Field_Refs) };
90 0 &_dumpValue ( $url, $object .": Unexpected key \"$key\" in record." );
91 }
92  
93 0 my $ref_type = '';
94  
95 0 ▶ if ( ($ref_type = ref $url->{$key}) && ( $ref_type ne Field_Refs->{$key}{type} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref_type = ref $url->{$key} and $ref_type ne {"Exp" => {"is_ref" => 0,"type" => "ARRAY"},"Exp_Fault" => {"is_ref" => 0,"type" => ""},"Exp_Return" => {"is_ref" => !!1,"type" => "HASH"},"Method" => {"is_ref" => 0,"type" => ""},"Msg" => {"is_ref" => 0,"type" => ""},"Msg_Fault" => {"is_ref" => 0,"type" => ""},"Perfdata_Label" => {"is_ref" => 0,"type" => undef},"Qs_fixed" => {"is_ref" => !!1,"type" => "ARRAY"},"Qs_var" => {"is_ref" => !!1,"type" => "ARRAY"},"Timeout" => {"is_ref" => 0,"type" => undef},"Url" => {"is_ref" => 0,"type" => ""}}->{$key}{"type"}) 0 0 0
Condition0%0/3
$ref_type = ref $url->{$key} and $ref_type ne {"Exp" => {"is_ref" => 0,"type" => "ARRAY"},"Exp_Fault" => {"is_ref" => 0,"type" => ""},"Exp_Return" => {"is_ref" => !!1,"type" => "HASH"},"Method" => {"is_ref" => 0,"type" => ""},"Msg" => {"is_ref" => 0,"type" => ""},"Msg_Fault" => {"is_ref" => 0,"type" => ""},"Perfdata_Label" => {"is_ref" => 0,"type" => undef},"Qs_fixed" => {"is_ref" => !!1,"type" => "ARRAY"},"Qs_var" => {"is_ref" => !!1,"type" => "ARRAY"},"Timeout" => {"is_ref" => 0,"type" => undef},"Url" => {"is_ref" => 0,"type" => ""}}->{$key}{"type"}
!ll&&!rl&&r
000
MC/DC0%0/2
$ref_type = ref $url->{$key} and $ref_type ne {"Exp" => {"is_ref" => 0,"type" => "ARRAY"},"Exp_Fault" => {"is_ref" => 0,"type" => ""},"Exp_Return" => {"is_ref" => !!1,"type" => "HASH"},"Method" => {"is_ref" => 0,"type" => ""},"Msg" => {"is_ref" => 0,"type" => ""},"Msg_Fault" => {"is_ref" => 0,"type" => ""},"Perfdata_Label" => {"is_ref" => 0,"type" => undef},"Qs_fixed" => {"is_ref" => !!1,"type" => "ARRAY"},"Qs_var" => {"is_ref" => !!1,"type" => "ARRAY"},"Timeout" => {"is_ref" => 0,"type" => undef},"Url" => {"is_ref" => 0,"type" => ""}}->{$key}{"type"}
$ref_type = ref $url->{$key} $ref_type ne {"Exp" => {"is_ref" => 0,"type" => "ARRAY"},"Exp_Fault" => {"is_ref" => 0,"type" => ""},"Exp_Return" => {"is_ref" => !!1,"type" => "HASH"},"Method" => {"is_ref" => 0,"type" => ""},"Msg" => {"is_ref" => 0,"type" => ""},"Msg_Fault" => {"is_ref" => 0,"type" => ""},"Perfdata_Label" => {"is_ref" => 0,"type" => undef},"Qs_fixed" => {"is_ref" => !!1,"type" => "ARRAY"},"Qs_var" => {"is_ref" => !!1,"type" => "ARRAY"},"Timeout" => {"is_ref" => 0,"type" => undef},"Url" => {"is_ref" => 0,"type" => ""}}->{$key}{"type"}
Truth table0%0/3
A and B
A= $ref_type = ref $url->{$key}B= $ref_type ne {"Exp" => {"is_ref" => 0,"type" => "ARRAY"},"Exp_Fault" => {"is_ref" => 0,"type" => ""},"Exp_Return" => {"is_ref" => !!1,"type" => "HASH"},"Method" => {"is_ref" => 0,"type" => ""},"Msg" => {"is_ref" => 0,"type" => ""},"Msg_Fault" => {"is_ref" => 0,"type" => ""},"Perfdata_Label" => {"is_ref" => 0,"type" => undef},"Qs_fixed" => {"is_ref" => !!1,"type" => "ARRAY"},"Qs_var" => {"is_ref" => !!1,"type" => "ARRAY"},"Timeout" => {"is_ref" => 0,"type" => undef},"Url" => {"is_ref" => 0,"type" => ""}}->{$key}{"type"}
ABresult
0X0
100
111
96 0 ▶ warn "Expected key \"$key\" to be ", Field_Refs->{$key}{type} ? Field_Refs->{$key}{type} .' ref' : 'non ref', "\n";
Branch: 1 branch
BranchTrueFalseTotal
{Exp => {is_ref => 0, type => 'ARRAY'}, Exp_Fault => {is_ref => 0, type => ''}, Exp_Return => {is_ref => 1, type => 'HASH'}, Method => {is_ref => 0, type => ''}, Msg => {is_ref => 0, type => ''}, Msg_Fault => {is_ref => 0, type => ''}, Perfdata_Label => {is_ref => 0, type => undef}, Qs_fixed => {is_ref => 1, type => 'ARRAY'}, Qs_var => {is_ref => 1, type => 'ARRAY'}, Timeout => {is_ref => 0, type => undef}, Url => {is_ref => 0, type => ''}}->{$key}{'type'} ? : 0 0 0
97 0 &_dumpValue ( $url, $object .": Field \"$key\" has wrong reference type" );
98 }
99  
100 0 ▶ if ( ! ref $url->{$key} and Field_Refs->{$key}{is_ref} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not ref $url->{$key} and {"Exp" => {"is_ref" => 0,"type" => "ARRAY"},"Exp_Fault" => {"is_ref" => 0,"type" => ""},"Exp_Return" => {"is_ref" => !!1,"type" => "HASH"},"Method" => {"is_ref" => 0,"type" => ""},"Msg" => {"is_ref" => 0,"type" => ""},"Msg_Fault" => {"is_ref" => 0,"type" => ""},"Perfdata_Label" => {"is_ref" => 0,"type" => undef},"Qs_fixed" => {"is_ref" => !!1,"type" => "ARRAY"},"Qs_var" => {"is_ref" => !!1,"type" => "ARRAY"},"Timeout" => {"is_ref" => 0,"type" => undef},"Url" => {"is_ref" => 0,"type" => ""}}->{$key}{"is_ref"}) 0 0 0
Condition0%0/3
not ref $url->{$key} and {"Exp" => {"is_ref" => 0,"type" => "ARRAY"},"Exp_Fault" => {"is_ref" => 0,"type" => ""},"Exp_Return" => {"is_ref" => !!1,"type" => "HASH"},"Method" => {"is_ref" => 0,"type" => ""},"Msg" => {"is_ref" => 0,"type" => ""},"Msg_Fault" => {"is_ref" => 0,"type" => ""},"Perfdata_Label" => {"is_ref" => 0,"type" => undef},"Qs_fixed" => {"is_ref" => !!1,"type" => "ARRAY"},"Qs_var" => {"is_ref" => !!1,"type" => "ARRAY"},"Timeout" => {"is_ref" => 0,"type" => undef},"Url" => {"is_ref" => 0,"type" => ""}}->{$key}{"is_ref"}
!ll&&!rl&&r
000
MC/DC0%0/2
not ref $url->{$key} and {"Exp" => {"is_ref" => 0,"type" => "ARRAY"},"Exp_Fault" => {"is_ref" => 0,"type" => ""},"Exp_Return" => {"is_ref" => !!1,"type" => "HASH"},"Method" => {"is_ref" => 0,"type" => ""},"Msg" => {"is_ref" => 0,"type" => ""},"Msg_Fault" => {"is_ref" => 0,"type" => ""},"Perfdata_Label" => {"is_ref" => 0,"type" => undef},"Qs_fixed" => {"is_ref" => !!1,"type" => "ARRAY"},"Qs_var" => {"is_ref" => !!1,"type" => "ARRAY"},"Timeout" => {"is_ref" => 0,"type" => undef},"Url" => {"is_ref" => 0,"type" => ""}}->{$key}{"is_ref"}
not ref $url->{$key} {"Exp" => {"is_ref" => 0,"type" => "ARRAY"},"Exp_Fault" => {"is_ref" => 0,"type" => ""},"Exp_Return" => {"is_ref" => !!1,"type" => "HASH"},"Method" => {"is_ref" => 0,"type" => ""},"Msg" => {"is_ref" => 0,"type" => ""},"Msg_Fault" => {"is_ref" => 0,"type" => ""},"Perfdata_Label" => {"is_ref" => 0,"type" => undef},"Qs_fixed" => {"is_ref" => !!1,"type" => "ARRAY"},"Qs_var" => {"is_ref" => !!1,"type" => "ARRAY"},"Timeout" => {"is_ref" => 0,"type" => undef},"Url" => {"is_ref" => 0,"type" => ""}}->{$key}{"is_ref"}
Truth table0%0/3
not(A) and B
A= not ref $url->{$key}B= {"Exp" => {"is_ref" => 0,"type" => "ARRAY"},"Exp_Fault" => {"is_ref" => 0,"type" => ""},"Exp_Return" => {"is_ref" => !!1,"type" => "HASH"},"Method" => {"is_ref" => 0,"type" => ""},"Msg" => {"is_ref" => 0,"type" => ""},"Msg_Fault" => {"is_ref" => 0,"type" => ""},"Perfdata_Label" => {"is_ref" => 0,"type" => undef},"Qs_fixed" => {"is_ref" => !!1,"type" => "ARRAY"},"Qs_var" => {"is_ref" => !!1,"type" => "ARRAY"},"Timeout" => {"is_ref" => 0,"type" => undef},"Url" => {"is_ref" => 0,"type" => ""}}->{$key}{"is_ref"}
ABresult
0X0
100
111
101 0 ▶ warn "Expected key \"$key\" to be ", Field_Refs->{$key}{type} ? Field_Refs->{$key}{type} .' ref' : 'non ref', "\n";
Branch: 1 branch
BranchTrueFalseTotal
{Exp => {is_ref => 0, type => 'ARRAY'}, Exp_Fault => {is_ref => 0, type => ''}, Exp_Return => {is_ref => 1, type => 'HASH'}, Method => {is_ref => 0, type => ''}, Msg => {is_ref => 0, type => ''}, Msg_Fault => {is_ref => 0, type => ''}, Perfdata_Label => {is_ref => 0, type => undef}, Qs_fixed => {is_ref => 1, type => 'ARRAY'}, Qs_var => {is_ref => 1, type => 'ARRAY'}, Timeout => {is_ref => 0, type => undef}, Url => {is_ref => 0, type => ''}}->{$key}{'type'} ? : 0 0 0
102 0 &_dumpValue ( $url, $object .": Key \"$key\" not a reference" );
103 }
104  
105 0 ▶ if ( $url->{$key} eq '' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($url->{$key} eq "") 0 0 0
106 0 warn "Expected key \"$key\" is empty\n";
107 0 &_dumpValue ( $url, $object .": Key \"$key\" is empty" );
108 }
109 }
110 }
111  
112 6 ▶ my $classname = ref ($object) || $object;
Condition33%1/3
ref $object || $object
l!l&&r!l&&!r
060
MC/DC0%0/2
ref $object || $object
ref $object $object
Truth table33%1/3
A || B
A= ref $objectB= $object
ABresult
1X1
011
000
113 6 my $accessor_stash_slot = $classname .'::'. 'get_urls';
114 25 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
115  
116 6 ▶ unless ( ref *$accessor_stash_slot{CODE} eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref *$accessor_stash_slot{"CODE"} eq "CODE") 6 0 6
117 6 foreach my $accessor ( qw(urls matches returns ua) ) {
118 24 my $full_name = $classname .'::'. $accessor;
119  
120 24 ▶ *{$full_name} = sub { my $self = shift @_;
Subroutine __ANON__: called CC=2 SCAR=7.0
121 13 ▶ $self->{$accessor} = shift @_ if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 13 13
122 13 $self->{$accessor};
123 24 };
124  
125 24 foreach my $acc_pre (qw(get set)) {
126 48 $full_name = $classname .'::'. $acc_pre .'_'. $accessor;
127 48 ▶ *{$full_name} = $acc_pre eq 'get' ? sub { my $self = shift @_; $self->{$accessor} } : sub { my $self = shift @_; $self->{$accessor} = shift @_ };
Subroutine __ANON__: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
$acc_pre eq 'get' ? : 24 24 48
128 }
129 }
130 }
131  
132 6 bless { asnmtapInherited => $asnmtapInherited, urls => $urls_ar, matches => [], returns => {}, ua => undef, newAgent => 1, number_of_images_downloaded => 0, _unknownErrors => 0, _KnownError => undef, _timing_tries => 0 }, $classname;
133 # The field urls contains a ref to a list of (hashes) records representing the web transaction.
134  
135 # self->_my_match() will update $self->{matches};
136 # with the set of matches it finds by matching patterns with memory (ie patterns in paren) from
137 # the Exp field against the request response.
138 # An array ref to the array containing the matches is stored in the field 'matches'.
139  
140 # Qs_var = [ form_name_1 => 0, form_name_2 => 1 ..] will lead to a query_string like
141 # form_name_1 = $matches[0] form_name_2 = $matches[1] .. in $self->_make_request() by
142 # @matches = $self->matches(); and using 0, 1 etc as indices of @matches.
143 }
144  
145 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
146  
147 9 ▶sub check {
Subroutine check: called CC=100 SCAR=81.9
Pod documented
148 9 my ($self, $cgi_parm_vals_hr) = @_;
149  
150 9 my %defaults = ( custom => undef,
151 perfdataLabel => undef,
152 newAgent => undef,
153 timeout => undef,
154 triesTiming => '1,3,15',
155 triesCodes => '408,500,502,503,504',
156 openAppend => TRUE,
157 cookies => TRUE,
158 protocol => TRUE,
159 keepAlive => TRUE,
160 download_images => FALSE,
161 fail_if_1 => TRUE );
162  
163 9 my %parms = (%defaults, @_);
164  
165 9 my $debug = ${$self->{asnmtapInherited}}->getOptionsValue ( 'debug' );
166 9 my $onDemand = ${$self->{asnmtapInherited}}->getOptionsValue ( 'onDemand' );
167 9 my $debugfile = ${$self->{asnmtapInherited}}->getOptionsArgv ( 'debugfile' );
168 9 my $openAppend = $parms{openAppend};
169 9 my $triesTiming = $parms{triesTiming};
170 9 my %triesCodesToDeterminate = map { $_ => 1 } ( $parms{triesCodes} =~ m<(\d+(?:\.\d+)*)>g );
171  
172 9 my $proxyServer = ${$self->{asnmtapInherited}}->proxy ( 'server' );
173 9 my $proxyUsername = ${$self->{asnmtapInherited}}->proxy ( 'username' );
174 9 my $proxyPassword = ${$self->{asnmtapInherited}}->proxy ( 'password' );
175  
176 9 ▶ $self->{newAgent} = $parms{newAgent} if ( defined $parms{newAgent} and defined $ua );
Branch: 1 branch
BranchTrueFalseTotal
if defined $parms{"newAgent"} and defined $ua 0 9 9
Condition33%1/3
defined $parms{"newAgent"} and defined $ua
!ll&&!rl&&r
900
MC/DC0%0/2
defined $parms{"newAgent"} and defined $ua
defined $parms{"newAgent"} defined $ua
Truth table33%1/3
A and B
A= defined $parms{"newAgent"}B= defined $ua
ABresult
0X0
100
111
177  
178 9 ▶ if ( $self->{newAgent} or ! defined $ua ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"newAgent"} or not defined $ua) 6 3 9
Condition66%2/3
$self->{"newAgent"} or not defined $ua
l!l&&r!l&&!r
603
MC/DC50%1/2
$self->{"newAgent"} or not defined $ua
$self->{"newAgent"} not defined $ua
Truth table66%2/3
A or not(B)
A= $self->{"newAgent"}B= not defined $ua
ABresult
1X1
011
000
179 6 $self->{newAgent} = 0;
180 6 ▶ LWP::Debug::level('+') if ( $debug );
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 6 6
181  
182 6 ▶ if ( $parms{keepAlive} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parms{'keepAlive'}) { } 6 0 6
183 6 $ua = LWP::UserAgent->new ( keep_alive => 1 );
184 } else {
185 0 $ua = LWP::UserAgent->new ( keep_alive => 0 );
186 }
187  
188 6 $self->{ua} = $ua;
189 6 $ua->agent ( ${$self->{asnmtapInherited}}->browseragent () );
190 6 $ua->timeout ( ${$self->{asnmtapInherited}}->timeout () );
191  
192 6 $ua->default_headers->push_header ( 'Accept-Language' => 'no, en' );
193 6 $ua->default_headers->push_header ( 'Accept-Charset' => 'iso-8859-1,*,utf-8' );
194 6 $ua->default_headers->push_header ( 'Accept-Encoding' => 'gzip, deflate' );
195  
196 6 ▶ $ua->default_headers->push_header ( 'Keep-Alive' => ${$self->{asnmtapInherited}}->timeout () ) if ( $parms{keepAlive} );
Branch: 1 branch
BranchTrueFalseTotal
if $parms{"keepAlive"} 6 0 6
197 6 $ua->default_headers->push_header ( 'Connection' => 'Keep-Alive' );
198  
199 6 ▶ if ( defined $proxyServer ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $proxyServer) 0 6 6
200 0 $ua->default_headers->push_header ( 'Proxy-Connection' => 'Keep-Alive' );
201  
202 # don't use $ua->proxy ( ['http', 'https', 'ftp'] => $proxyServer ); or $ua->proxy ( 'https' => undef ) ;
203 0 $ua->proxy ( ['http', 'ftp'] => $proxyServer );
204  
205 # do not proxy requests to the given domains. Calling no_proxy without any domains clears the list of domains.
206 0 ▶ ( defined ${$self->{asnmtapInherited}}->proxy ( 'no' ) and ${$self->{asnmtapInherited}}->proxy ( 'no' ) ne '' ? $ua->no_proxy( @{ ${$self->{asnmtapInherited}}->proxy ( 'no' ) } ) : $ua->no_proxy( ) ) ;
Branch: 2 branches
BranchTrueFalseTotal
defined ${$$self{"asnmtapInherited"};}->proxy("no") and ${$$self{"asnmtapInherited"};}->proxy("no") ne "" ? $ua->no_proxy(@{${$$self{"asnmtapInherited"};}->proxy("no");}) : $ua->no_proxy 0 0 0
${$$self{'asnmtapInherited'};}->proxy('no') ne '' ? : 0 0 0
207 }
208  
209 6 ▶ $ua->cookie_jar ( HTTP::Cookies->new ) if ( $parms{cookies} );
Branch: 1 branch
BranchTrueFalseTotal
if $parms{"cookies"} 6 0 6
210 }
211  
212 9 ▶ if ( defined $parms{timeout} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $parms{"timeout"}) 0 9 9
213 0 $ua->timeout ( $parms{timeout} );
214 0 ▶ $ua->default_headers->push_header ( 'Keep-Alive' => $parms{timeout} ) if ( $parms{keepAlive} );
Branch: 1 branch
BranchTrueFalseTotal
if $parms{"keepAlive"} 0 0 0
215 }
216  
217 9 ▶ my $returnCode = $parms{fail_if_1} ? $ERRORS{OK} : $ERRORS{CRITICAL};
Branch: 1 branch
BranchTrueFalseTotal
$parms{'fail_if_1'} ? : 9 0 9
218 9 my ($response_as_content, $response, $found);
219  
220 9 my $startTime;
221  
222 9 ▶ if ( defined $parms{perfdataLabel} and $parms{perfdataLabel} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $parms{"perfdataLabel"} and $parms{"perfdataLabel"}) 0 9 9
Condition33%1/3
defined $parms{"perfdataLabel"} and $parms{"perfdataLabel"}
!ll&&!rl&&r
900
MC/DC0%0/2
defined $parms{"perfdataLabel"} and $parms{"perfdataLabel"}
defined $parms{"perfdataLabel"} $parms{"perfdataLabel"}
Truth table33%1/3
A and B
A= defined $parms{"perfdataLabel"}B= $parms{"perfdataLabel"}
ABresult
0X0
100
111
223 0 ${$self->{asnmtapInherited}}->setEndTime_and_getResponsTime ( ${$self->{asnmtapInherited}}->pluginValue ('endTime') );
224 0 $startTime = ${$self->{asnmtapInherited}}->pluginValue ('endTime');
225 }
226  
227 9 my $statusTimeout;
228  
229 9 foreach my $url_r ( @{ $self->{urls} } ) {
230 9 ▶ if ( defined $url_r->{Timeout} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $url_r->{'Timeout'}) { } 0 9 9
elsif (defined $statusTimeout) { } 0 9 9
231 0 $statusTimeout = 1;
232 0 $ua->timeout ( $url_r->{Timeout} );
233 0 ▶ $ua->default_headers->push_header ( 'Keep-Alive' => $url_r->{Timeout} ) if ( $parms{keepAlive} );
Branch: 1 branch
BranchTrueFalseTotal
if $parms{"keepAlive"} 0 0 0
234 } elsif ( defined $statusTimeout ) {
235 0 $statusTimeout = undef;
236  
237 0 ▶ if ( defined $parms{timeout} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $parms{'timeout'}) { } 0 0 0
238 0 $ua->timeout ( $parms{timeout} );
239 0 ▶ $ua->default_headers->push_header ( 'Keep-Alive' => $parms{timeout} ) if ( $parms{keepAlive} );
Branch: 1 branch
BranchTrueFalseTotal
if $parms{"keepAlive"} 0 0 0
240 } else {
241 0 $ua->timeout ( ${$self->{asnmtapInherited}}->timeout () );
242 0 ▶ $ua->default_headers->push_header ( 'Keep-Alive' => ${$self->{asnmtapInherited}}->timeout () ) if ( $parms{keepAlive} );
Branch: 1 branch
BranchTrueFalseTotal
if $parms{"keepAlive"} 0 0 0
243 }
244 }
245  
246 9 $self->{_KnownError} = undef;
247 9 ${$self->{asnmtapInherited}}->setEndTime_and_getResponsTime ( ${$self->{asnmtapInherited}}->pluginValue ('endTime') );
248  
249 9 ▶ my $url = $url_r->{Url} ? $url_r->{Url} : &_next_url ($response, $response_as_content);
Branch: 1 branch
BranchTrueFalseTotal
$url_r->{'Url'} ? : 9 0 9
250 9 my $request = $self->_make_request ( $url_r->{Method}, $url, $url_r->{Qs_var}, $url_r->{Qs_fixed}, $cgi_parm_vals_hr );
251 9 ▶ $request->protocol ('HTTP/1.1') if ( $parms{protocol} );
Branch: 1 branch
BranchTrueFalseTotal
if $parms{"protocol"} 9 0 9
252 9 ▶ $request->proxy_authorization_basic ( $proxyUsername, $proxyPassword ) if ( defined $proxyServer && defined $proxyUsername && defined $proxyPassword );
Branch: 1 branch
BranchTrueFalseTotal
if defined $proxyServer and defined $proxyUsername and defined $proxyPassword 0 9 9
Condition33%2/6
defined $proxyServer and defined $proxyUsername and defined $proxyPassword
!ll&&!rl&&r
900
defined $proxyServer and defined $proxyUsername
!ll&&!rl&&r
900
MC/DC0%0/3
defined $proxyServer and defined $proxyUsername and defined $proxyPassword
defined $proxyServer defined $proxyUsername defined $proxyPassword
Truth table25%1/4
A and B and C
A= defined $proxyServerB= defined $proxyUsernameC= defined $proxyPassword
ABCresult
0XX0
10X0
1100
1111
253  
254 9 my $request_as_string = $request->as_string;
255 9 ▶ print "\n", ref ($self), '::send_request: ', $request_as_string, "\n" if ( $debug );
Branch: 1 branch
BranchTrueFalseTotal
if $debug 0 9 9
256  
257 9 ▶ if ( defined $triesTiming and $triesTiming ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $triesTiming and $triesTiming) { } 9 0 9
Condition33%1/3
defined $triesTiming and $triesTiming
!ll&&!rl&&r
009
MC/DC0%0/2
defined $triesTiming and $triesTiming
defined $triesTiming $triesTiming
Truth table33%1/3
A and B
A= defined $triesTimingB= $triesTiming
ABresult
0X0
100
111
258 9 my (@timing_tries) = ( $triesTiming =~ m<(\d+(?:\.\d+)*)>g );
259 9 LWP::Debug::debug ('My retrial code policy is ['. join(' ', sort keys %triesCodesToDeterminate) .'].');
260 9 LWP::Debug::debug ('My retrial timing policy is ['. $triesTiming .'].');
261 9 my $timing_tries = 0;
262  
263 9 foreach my $pause_if_unsuccessful ( @timing_tries, undef ) {
264 36 $response = $ua->request ($request);
265 36 my $code = $response->code;
266 36 my $message = $response->message;
267 36 $message =~ s/\s+$//s;
268 36 $timing_tries++;
269  
270 36 ▶ unless( $triesCodesToDeterminate{$code} ) { # normal case: all is well (or 404, etc)
Branch: 1 branch
BranchTrueFalseTotal
unless ($triesCodesToDeterminate{$code}) 0 36 36
271 0 LWP::Debug::debug ("It returned a code ($code $message) blocking a retry");
272 0 last;
273 }
274  
275 36 ▶ if ( defined $pause_if_unsuccessful ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $pause_if_unsuccessful) { } 27 9 36
276 27 LWP::Debug::debug ("It returned a code ($code $message) that'll make me retry, after $pause_if_unsuccessful seconds.");
277 27 ▶ sleep $pause_if_unsuccessful if ( $pause_if_unsuccessful );
Branch: 1 branch
BranchTrueFalseTotal
if $pause_if_unsuccessful 27 0 27
278 27 $self->{_timing_tries}++;
279 } else {
280 9 LWP::Debug::debug ("I give up. I'm returning this '$code $message' response.");
281 }
282 }
283  
284 9 ▶ print ref ($self), '::timing_tries: ', $timing_tries, " - $url\n" if ( $onDemand );
Branch: 1 branch
BranchTrueFalseTotal
if $onDemand 0 9 9
285 } else {
286 0 $response = $ua->request ($request);
287 }
288  
289 9 ▶ if ( defined $response->content_encoding and $response->content_encoding =~ /^gzip$/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $response->content_encoding and $response->content_encoding =~ /^gzip$/i) { } 0 9 9
Condition33%1/3
defined $response->content_encoding and $response->content_encoding =~ /^gzip$/i
!ll&&!rl&&r
900
MC/DC0%0/2
defined $response->content_encoding and $response->content_encoding =~ /^gzip$/i
defined $response->content_encoding $response->content_encoding =~ /^gzip$/i
Truth table33%1/3
A and B
A= defined $response->content_encodingB= $response->content_encoding =~ /^gzip$/i
ABresult
0X0
100
111
290 25 ▶ use Compress::Zlib;
Subroutine BEGIN: called CC=1 SCAR=0.0
291 0 $response_as_content = Compress::Zlib::memGunzip ( $response->content );
292 } else {
293 9 $response_as_content = $response->content;
294 }
295  
296 9 ▶ if ( $debug >= 3 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($debug >= 3) { } 0 9 9
elsif ($debug >= 2) { } 0 9 9
297 0 print "\n", ref ($self), '::request: ()', "\n", $response->as_string, "\n\n";
298 } elsif ( $debug >= 2 ) {
299 0 print "\n", ref ($self), '::content: ()', "\n", $response_as_content, "\n\n";
300 }
301  
302 9 my $responseTime = ${$self->{asnmtapInherited}}->setEndTime_and_getResponsTime ( ${$self->{asnmtapInherited}}->pluginValue ('endTime') );
303 9 ▶ print ref ($self), '::response_time: ', $responseTime, " - $url\n" if ( $onDemand );
Branch: 1 branch
BranchTrueFalseTotal
if $onDemand 0 9 9
304 9 ▶ ${$self->{asnmtapInherited}}->appendPerformanceData ( "'". $url_r->{Perfdata_Label} ."'=". $responseTime .'ms;;;;' ) if ( defined $url_r->{Perfdata_Label} );
Branch: 1 branch
BranchTrueFalseTotal
if defined $url_r->{"Perfdata_Label"} 3 6 9
305  
306 9 ▶ $self->_write_debugfile ( $request_as_string, $response_as_content, $debugfile, $openAppend ) if ( defined $debugfile );
Branch: 1 branch
BranchTrueFalseTotal
if defined $debugfile 0 9 9
307  
308 9 ▶ if ( $parms{fail_if_1} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parms{'fail_if_1'}) { } 9 0 9
309 9 ▶ unless ( $response->is_success or $response->is_redirect ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($response->is_success or $response->is_redirect) 9 0 9
Condition33%1/3
$response->is_success or $response->is_redirect
l!l&&r!l&&!r
009
MC/DC0%0/2
$response->is_success or $response->is_redirect
$response->is_success $response->is_redirect
Truth table33%1/3
A or B
A= $response->is_successB= $response->is_redirect
ABresult
1X1
011
000
310 9 my $response_as_request = $response->as_string;
311  
312 # Deal with __Can't__ from LWP.
313 # Otherwise notification fails because /bin/sh is called to
314 # printf '$OUTPUT' and sh cannot deal with nested quotes (eg Can't echo ''')
315 9 $response_as_request =~ s#'#_#g;
316  
317 9 $returnCode = $ERRORS{CRITICAL};
318 9 my $knownError = 0;
319 9 my $errorMessage = "other than HTTP 200";
320  
321 9 for ( $response_as_request ) {
322 # ***************************************************************************
323 # The 500 series of Web error codes indicate an error with the Web server *
324 # ***************************************************************************
325  
326 # The server had some sort of internal error trying to fulfil the request. The client may see a partial page or error message.
327 # It's a fault in the server and happens all too frequently.
328 9 ▶ /500 Can_t connect to/ && do { $knownError = 1; $errorMessage = "500 Can't connect to ..."; $returnCode = $ERRORS{UNKNOWN}; last; };
Branch: 1 branch
BranchTrueFalseTotal
/500 Can_t connect to/ and do { $knownError = 1; $errorMessage = "500 Can't connect to ..."; $returnCode = $ASNMTAP::Asnmtap::Plugins::WebTransact::ERRORS{"UNKNOWN"}; last } 9 0 9
329 0 ▶ /500 Connect failed/ && do { $knownError = 1; $errorMessage = "500 Connect failed"; $returnCode = $ERRORS{UNKNOWN}; last; };
Branch: 1 branch
BranchTrueFalseTotal
/500 Connect failed/ and do { $knownError = 1; $errorMessage = "500 Connect failed"; $returnCode = $ASNMTAP::Asnmtap::Plugins::WebTransact::ERRORS{"UNKNOWN"}; last } 0 0 0
330 0 ▶ /500 proxy connect failed/ && do { $knownError = 1; $errorMessage = "500 Proxy connect failed"; $returnCode = $ERRORS{UNKNOWN}; last; };
Branch: 1 branch
BranchTrueFalseTotal
/500 proxy connect failed/ and do { $knownError = 1; $errorMessage = "500 Proxy connect failed"; $returnCode = $ASNMTAP::Asnmtap::Plugins::WebTransact::ERRORS{"UNKNOWN"}; last } 0 0 0
331 0 ▶ /500 Server Error/ && do { $knownError = 1; $errorMessage = "500 Server Error"; $returnCode = $ERRORS{UNKNOWN}; last; };
Branch: 1 branch
BranchTrueFalseTotal
/500 Server Error/ and do { $knownError = 1; $errorMessage = "500 Server Error"; $returnCode = $ASNMTAP::Asnmtap::Plugins::WebTransact::ERRORS{"UNKNOWN"}; last } 0 0 0
332 0 ▶ /500 SSL negotiation failed/ && do { $knownError = 1; $errorMessage = "500 SSL negotiation failed"; $returnCode = $ERRORS{UNKNOWN}; last; };
Branch: 1 branch
BranchTrueFalseTotal
/500 SSL negotiation failed/ and do { $knownError = 1; $errorMessage = "500 SSL negotiation failed"; $returnCode = $ASNMTAP::Asnmtap::Plugins::WebTransact::ERRORS{"UNKNOWN"}; last } 0 0 0
333 0 ▶ /500 SSL read timeout/ && do { $knownError = 1; $errorMessage = "500 SSL read timeout"; $returnCode = $ERRORS{UNKNOWN}; last; };
Branch: 1 branch
BranchTrueFalseTotal
/500 SSL read timeout/ and do { $knownError = 1; $errorMessage = "500 SSL read timeout"; $returnCode = $ASNMTAP::Asnmtap::Plugins::WebTransact::ERRORS{"UNKNOWN"}; last } 0 0 0
334  
335 0 ▶ /Internal Server Error/ && do { $knownError = 0; $errorMessage = "500 Internal Server Error"; $returnCode = $ERRORS{UNKNOWN}; last; };
Branch: 1 branch
BranchTrueFalseTotal
/Internal Server Error/ and do { $knownError = 0; $errorMessage = "500 Internal Server Error"; $returnCode = $ASNMTAP::Asnmtap::Plugins::WebTransact::ERRORS{"UNKNOWN"}; last } 0 0 0
336  
337 # Function not implemented in Web server software. The request needs functionality not available on the server
338 0 ▶ /501 (?:No Server|Not Implemented)/ && do { $errorMessage = "501 Not Implemented"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/501 (?:No Server|Not Implemented)/ and do { $errorMessage = "501 Not Implemented"; last } 0 0 0
339  
340 # Bad Gateway: a server being used by this Web server has sent an invalid response.
341 # The response by an intermediary server was invalid. This may happen if there is a problem with the DNS routing tables.
342 0 ▶ /502 (?:Bad Gateway|Server Overload)/ && do { $knownError = 1; $errorMessage = "502 Bad Gateway"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/502 (?:Bad Gateway|Server Overload)/ and do { $knownError = 1; $errorMessage = "502 Bad Gateway"; last } 0 0 0
343  
344 # Service temporarily unavailable because of currently/temporary overload or maintenance.
345 0 ▶ /503 (?:Out of Resources|Service Unavailable)/ && do { $knownError = 1; $errorMessage = "503 Service Unavailable"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/503 (?:Out of Resources|Service Unavailable)/ and do { $knownError = 1; $errorMessage = "503 Service Unavailable"; last } 0 0 0
346  
347 # The server did not respond back to the gateway within acceptable time period
348 0 ▶ /504 Gateway Time-?Out/ && do { $knownError = 1; $errorMessage = "504 Gateway Timeout"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/504 Gateway Time-?Out/ and do { $knownError = 1; $errorMessage = "504 Gateway Timeout"; last } 0 0 0
349  
350 # The server does not support the HTTP protocol version that was used in the request message.
351 0 ▶ /505 HTTP Version [nN]ot supported/ && do { $knownError = 1; $errorMessage = "505 HTTP Version Not Supported"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/505 HTTP Version [nN]ot supported/ and do { $knownError = 1; $errorMessage = "505 HTTP Version Not Supported"; last } 0 0 0
352  
353 # ***************************************************************************
354 # The 400 series of Web error codes indicate an error with your Web browser *
355 # ***************************************************************************
356  
357 # The request could not be understood by the server due to incorrect syntax.
358 0 ▶ /400 Bad Request/ && do { $knownError = 1; $errorMessage = "400 Bad Request"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/400 Bad Request/ and do { $knownError = 1; $errorMessage = "400 Bad Request"; last } 0 0 0
359  
360 # The client does not have access to this resource, authorization is needed
361 0 ▶ /401 (?:Unauthorized|Authorization Required)/ && do { $knownError = 1; $errorMessage = "401 Unauthorized User"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/401 (?:Unauthorized|Authorization Required)/ and do { $knownError = 1; $errorMessage = "401 Unauthorized User"; last } 0 0 0
362  
363 # Payment is required. Reserved for future use
364 0 ▶ /402 Payment Required/ && do { $knownError = 1; $errorMessage = "402 Payment Required"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/402 Payment Required/ and do { $knownError = 1; $errorMessage = "402 Payment Required"; last } 0 0 0
365  
366 # The server understood the request, but is refusing to fulfill it. Access to a resource is not allowed.
367 # The most frequent case of this occurs when directory listing access is not allowed.
368 0 ▶ /403 Forbidden/ && do { $knownError = 1; $errorMessage = "403 Forbidden Connection"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/403 Forbidden/ and do { $knownError = 1; $errorMessage = "403 Forbidden Connection"; last } 0 0 0
369  
370 # The resource request was not found. This is the code returned for missing pages or graphics.
371 # Viruses will often attempt to access resources that do not exist, so the error does not necessarily represent a problem.
372 0 ▶ /404 (?:Page )?Not Found/ && do { $knownError = 1; $errorMessage = "404 Page Not Found"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/404 (?:Page )?Not Found/ and do { $knownError = 1; $errorMessage = "404 Page Not Found"; last } 0 0 0
373  
374 # The access method (GET, POST, HEAD) is not allowed on this resource
375 0 ▶ /405 Method Not Allowed/ && do { $knownError = 1; $errorMessage = "405 Method Not Allowed"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/405 Method Not Allowed/ and do { $knownError = 1; $errorMessage = "405 Method Not Allowed"; last } 0 0 0
376  
377 # None of the acceptable file types (as requested by client) are available for this resource
378 0 ▶ /406 Not Acceptable/ && do { $errorMessage = "406 Not Acceptable"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/406 Not Acceptable/ and do { $errorMessage = "406 Not Acceptable"; last } 0 0 0
379  
380 # The client does not have access to this resource, proxy authorization is needed
381 0 ▶ /407 Proxy Authentication Required/ && do { $knownError = 1; $errorMessage = "407 Proxy Authentication Required"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/407 Proxy Authentication Required/ and do { $knownError = 1; $errorMessage = "407 Proxy Authentication Required"; last } 0 0 0
382  
383 # The client did not send a request within the required time period
384 0 ▶ /408 Request Time(?:[- ])?[oO]ut/ && do { $knownError = 1; $errorMessage = "408 Request Timeout"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/408 Request Time(?:[- ])?[oO]ut/ and do { $knownError = 1; $errorMessage = "408 Request Timeout"; last } 0 0 0
385  
386 # The request could not be completed due to a conflict with the current state of the resource.
387 0 ▶ /409 Conflict/ && do { $knownError = 1; $errorMessage = "409 Conflict"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/409 Conflict/ and do { $knownError = 1; $errorMessage = "409 Conflict"; last } 0 0 0
388  
389 # The requested resource is no longer available at the server and no forwarding address is known.
390 # This condition is similar to 404, except that the 410 error condition is expected to be permanent.
391 # Any robot seeing this response should delete the reference from its information store.
392 0 ▶ /410 Gone/ && do { $knownError = 1; $errorMessage = "410 Gone"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/410 Gone/ and do { $knownError = 1; $errorMessage = "410 Gone"; last } 0 0 0
393  
394 # The request requires the Content-Length HTTP request field to be specified
395 0 ▶ /411 (?:Content )?Length Required/ && do { $knownError = 1; $errorMessage = "411 Length Required"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/411 (?:Content )?Length Required/ and do { $knownError = 1; $errorMessage = "411 Length Required"; last } 0 0 0
396  
397 # The precondition given in one or more of the request-header fields evaluated to false when it was tested on the server.
398 0 ▶ /412 Precondition Failed/ && do { $knownError = 1; $errorMessage = "412 Precondition Failed"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/412 Precondition Failed/ and do { $knownError = 1; $errorMessage = "412 Precondition Failed"; last } 0 0 0
399  
400 # The server is refusing to process a request because the request entity is larger than the server is willing or able to process.
401 0 ▶ /413 Request Entity Too Large/ && do { $knownError = 1; $errorMessage = "413 Request Entity Too Large"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/413 Request Entity Too Large/ and do { $knownError = 1; $errorMessage = "413 Request Entity Too Large"; last } 0 0 0
402  
403 # The server is refusing to service the request because the Request-URI is longer than the server is willing to interpret.
404 # The URL is too long (possibly too many query keyword/value pairs)
405 0 ▶ /414 Request[- ]URL Too Large/ && do { $knownError = 1; $errorMessage = "414 Request URL Too Large"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/414 Request[- ]URL Too Large/ and do { $knownError = 1; $errorMessage = "414 Request URL Too Large"; last } 0 0 0
406  
407 # The server is refusing to service the request because the entity of the request is in a format not supported by the requested resource for the requested method.
408 0 ▶ /415 Unsupported Media Type/ && do { $knownError = 1; $errorMessage = "415 Unsupported Media Type"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/415 Unsupported Media Type/ and do { $knownError = 1; $errorMessage = "415 Unsupported Media Type"; last } 0 0 0
409  
410 # The portion of the resource requested is not available or out of range
411 0 ▶ /416 Requested Range (?:Invalid|Not Satisfiable)/ && do { $knownError = 1; $errorMessage = "416 Requested Range Invalid"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/416 Requested Range (?:Invalid|Not Satisfiable)/ and do { $knownError = 1; $errorMessage = "416 Requested Range Invalid"; last } 0 0 0
412  
413 # The Expect specifier in the HTTP request header can not be met
414 0 ▶ /417 Expectation Failed/ && do { $knownError = 1; $errorMessage = "417 Expectation Failed"; last; };
Branch: 1 branch
BranchTrueFalseTotal
/417 Expectation Failed/ and do { $knownError = 1; $errorMessage = "417 Expectation Failed"; last } 0 0 0
415 }
416  
417 9 ${$self->{asnmtapInherited}}->pluginValues ( { stateValue => $returnCode, alert => "'". $errorMessage ."' - ". $url_r->{Msg}, error => &_error_message( $request->method .' '. $request->uri ), result => $response_as_content }, $TYPE{REPLACE} );
418 9 ▶ $self->{_KnownError} = $debugfile if ( defined $debugfile and $knownError );
Branch: 1 branch
BranchTrueFalseTotal
if defined $debugfile and $knownError 0 9 9
Condition33%1/3
defined $debugfile and $knownError
!ll&&!rl&&r
900
MC/DC0%0/2
defined $debugfile and $knownError
defined $debugfile $knownError
Truth table33%1/3
A and B
A= defined $debugfileB= $knownError
ABresult
0X0
100
111
419 9 ▶ $self->{_unknownErrors}++ unless ( $knownError );
Branch: 1 branch
BranchTrueFalseTotal
unless $knownError 0 9 9
420 9 return ( $returnCode );
421 }
422 } else {
423 0 ▶ $returnCode = $ERRORS{OK} if $response->is_success;
Branch: 1 branch
BranchTrueFalseTotal
if $response->is_success 0 0 0
424 }
425  
426 0 ▶ if ( $parms{custom} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parms{"custom"}) 0 0 0
427 0 my ($returnCode, $knownError, $errorMessage) = $parms{custom}->( $response_as_content );
428  
429 0 ▶ if ( $returnCode != $ERRORS{OK} and defined $errorMessage ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($returnCode != $ASNMTAP::Asnmtap::Plugins::WebTransact::ERRORS{"OK"} and defined $errorMessage) 0 0 0
Condition0%0/3
$returnCode != $ASNMTAP::Asnmtap::Plugins::WebTransact::ERRORS{"OK"} and defined $errorMessage
!ll&&!rl&&r
000
MC/DC0%0/2
$returnCode != $ASNMTAP::Asnmtap::Plugins::WebTransact::ERRORS{"OK"} and defined $errorMessage
$returnCode != $ASNMTAP::Asnmtap::Plugins::WebTransact::ERRORS{"OK"} defined $errorMessage
Truth table0%0/3
A and B
A= $returnCode != $ASNMTAP::Asnmtap::Plugins::WebTransact::ERRORS{"OK"}B= defined $errorMessage
ABresult
0X0
100
111
430 0 ${$self->{asnmtapInherited}}->pluginValues ( { stateValue => $returnCode, alert => $errorMessage .' - '. $url_r->{Msg}, error => &_error_message ( $request->method .' '. $request->uri ), result => $response_as_content }, $TYPE{REPLACE} );
431 0 ▶ $self->{_KnownError} = $debugfile if ( defined $debugfile and $knownError );
Branch: 1 branch
BranchTrueFalseTotal
if defined $debugfile and $knownError 0 0 0
Condition0%0/3
defined $debugfile and $knownError
!ll&&!rl&&r
000
MC/DC0%0/2
defined $debugfile and $knownError
defined $debugfile $knownError
Truth table0%0/3
A and B
A= defined $debugfileB= $knownError
ABresult
0X0
100
111
432 0 ▶ $self->{_unknownErrors}++ unless ( $knownError );
Branch: 1 branch
BranchTrueFalseTotal
unless $knownError 0 0 0
433 0 return ( $returnCode );
434 }
435 }
436  
437 0 $self->_my_return ( $url_r->{Exp_Return}, $response_as_content );
438  
439 0 ▶ if ( $self->_my_match ( $url_r->{Exp_Fault}, $response_as_content, 0 ) ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->_my_match($url_r->{'Exp_Fault'}, $response_as_content, 0)) { } 0 0 0
elsif (not $found = $self->_my_match($url_r->{'Exp'}, $response_as_content, 1)) { } 0 0 0
elsif (ref $url_r->{'Exp'} eq 'ARRAY') { } 0 0 0
440 0 my $fault_ind = $url_r->{Exp_Fault};
441 0 my ($bad_stuff) = $response_as_content =~ /($fault_ind.*\n.*\n)/;
442 0 ${$self->{asnmtapInherited}}->pluginValues ( { stateValue => $ERRORS{CRITICAL}, alert => $url_r->{Msg_Fault}, error => &_error_message ( $request->method .' '. $request->uri ), result => $bad_stuff }, $TYPE{REPLACE} );
443 0 $self->{_unknownErrors}++;
444 0 return ( $ERRORS{CRITICAL} );
445 } elsif ( ! ($found = $self->_my_match ( $url_r->{Exp}, $response_as_content, 1 )) ) {
446 0 my $exp_type = ref $url_r->{Exp};
447 0 ▶ my $exp_str = $exp_type eq 'ARRAY' ? "@{$url_r->{Exp}}" : $url_r->{Exp};
Branch: 1 branch
BranchTrueFalseTotal
$exp_type eq 'ARRAY' ? : 0 0 0
448 0 ${$self->{asnmtapInherited}}->pluginValues ( { stateValue => $ERRORS{CRITICAL}, alert => "'". $url_r->{Msg} ."' - '". $exp_str ."' not in response", error => &_error_message ( $request->method .' '. $request->uri ), result => $response_as_content }, $TYPE{REPLACE} );
449 0 $self->{_unknownErrors}++;
450 0 return ( $ERRORS{CRITICAL} );
451 } elsif (ref $url_r->{Exp} eq 'ARRAY') {
452 0 my $exp_array = @{$url_r->{Exp}};
453  
454 0 ▶ if ( $exp_array != $found ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exp_array != $found) 0 0 0
455 0 ${$self->{asnmtapInherited}}->pluginValues ( { stateValue => $ERRORS{CRITICAL}, alert => "'". $url_r->{Msg} ."' - '". ( $exp_array - $found ) ."' element(s) not in response", error => &_error_message ( $request->method .' '. $request->uri ), result => $response_as_content }, $TYPE{REPLACE} );
456 0 $self->{_unknownErrors}++;
457 0 return ( $ERRORS{CRITICAL} );
458 }
459 }
460  
461 0 ▶ if ( $parms{download_images} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parms{"download_images"}) 0 0 0
462 0 my ($image_dl_nok, $image_dl_msg, $number_imgs_dl) = $self->_download_images ($response, \%parms, \%downloaded);
463  
464 0 ▶ if ( $image_dl_nok ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($image_dl_nok) 0 0 0
465 0 ${$self->{asnmtapInherited}}->pluginValues ( { stateValue => $ERRORS{CRITICAL}, error => $image_dl_msg }, $TYPE{REPLACE} );
466 0 $self->{_unknownErrors}++;
467 0 return ( $ERRORS{CRITICAL} );
468 }
469  
470 0 $self->{number_of_images_downloaded} += $number_imgs_dl;
471 }
472 }
473  
474 0 ▶ if ( defined $parms{perfdataLabel} and defined $startTime ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $parms{"perfdataLabel"} and defined $startTime) 0 0 0
Condition0%0/3
defined $parms{"perfdataLabel"} and defined $startTime
!ll&&!rl&&r
000
MC/DC0%0/2
defined $parms{"perfdataLabel"} and defined $startTime
defined $parms{"perfdataLabel"} defined $startTime
Truth table0%0/3
A and B
A= defined $parms{"perfdataLabel"}B= defined $startTime
ABresult
0X0
100
111
475 0 my $responseTime = ${$self->{asnmtapInherited}}->setEndTime_and_getResponsTime ( $startTime );
476 0 ${$self->{asnmtapInherited}}->appendPerformanceData ( "'". $parms{perfdataLabel} ."'=". $responseTime .'ms;;;;' );
477 }
478  
479 0 ▶ ${$self->{asnmtapInherited}}->pluginValues ( { stateValue => $returnCode, alert => ( ( $parms{download_images} and ! $returnCode ) ? "downloaded $self->{number_of_images_downloaded} images" : undef ), error => ( $returnCode ? '?' : undef ), result => $response_as_content }, $TYPE{REPLACE} );
Branch: 2 branches
BranchTrueFalseTotal
$parms{'download_images'} && !$returnCode ? : 0 0 0
$returnCode ? : 0 0 0
Condition0%0/3
$parms{"download_images"} and not $returnCode
!ll&&!rl&&r
000
MC/DC0%0/2
$parms{"download_images"} and not $returnCode
$parms{"download_images"} not $returnCode
Truth table0%0/3
A and not(B)
A= $parms{"download_images"}B= not $returnCode
ABresult
0X0
100
111
480 0 return ( $returnCode );
481 }
482  
483 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
484  
485 0 ▶sub _download_images {
Subroutine _download_images: not called CC=2 SCAR=17.9
486 0 my ($self, $response, $parms_hr, $downloaded_hr) = @_;
487  
488 0 require HTML::LinkExtor;
489 0 require URI::URL;
490 0 URI::URL->import(qw(url));
491  
492 0 my @imgs = ();
493  
494 0 ▶ my $cb = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
495 0 my ($tag, %attr) = @_;
496 0 ▶ return if $tag ne 'img'; # we only look closer at <img ...>
Branch: 1 branch
BranchTrueFalseTotal
if $tag ne "img" 0 0 0
497 0 push (@imgs, $attr{src});
498 0 };
499  
500 0 my $p = HTML::LinkExtor->new($cb);
501 0 $p->parse($response->as_string);
502 0 my $base = $response->base;
503 0 my @imgs_abs = grep ! $downloaded_hr->{$_}++, map { my $x = url($_, $base)->abs; } @imgs;
504 0 my @img_urls = map { Method => 'GET', Url => $_->as_string, Qs_var => [], Qs_fixed => [], Exp => '.', Exp_Fault => 'NeverInAnImage', Msg => '.', Msg_Fault => 'NeverInAnImage', Perfdata_Label => $_->as_string }, @imgs_abs;
505  
506 # url() returns an array ref containing the abs url and the base.
507 0 ▶ if ( my $number_of_images_not_already_downloaded = scalar @img_urls ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $number_of_images_not_already_downloaded = scalar @img_urls) { } 0 0 0
508 0 my $img_trx = __PACKAGE__->new( $self->{asnmtapInherited}, \@img_urls );
509 0 my %image_dl_parms = (%$parms_hr, fail_if_1 => FALSE, download_images => FALSE);
510 0 return ( $img_trx->check( {}, %image_dl_parms), 'Downloaded not all '. $number_of_images_not_already_downloaded .' images found in '. $response->base, $number_of_images_not_already_downloaded );
511 } else {
512 0 return ( $ERRORS{OK}, 'Downloaded all __zero__ images found in '. $response->base, 0 );
513 }
514 }
515  
516 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
517  
518 9 ▶sub _make_request {
Subroutine _make_request: called CC=11 SCAR=34.3
519 9 my ($self, $method, $url, $qs_var_ar, $qs_fixed_ar, $name_vals_hr) = @_;
520  
521 # $qs_var_ar is an array reference containing the name value pairs of any parameters whose
522 # value is known only at run time
523  
524 # the format of $qs_var_ar is [cgi_parm_name => val, cg_parm_name => val ..]
525 # where cgi_parm_name is the name of a fill out form parameter and val is a string used as a
526 # key in %$name_vals_hr to get the value of the cgi_parameter.
527  
528 # eg [p_tm_number, tmno] has the parameter name 'p_tm_number' and val 'tmno'.
529  
530 # If $name_vals_hr = { tmno = > 1 }, the query_sring becomes p_tm_number=1
531  
532 # when the val is a digit, that digit is interpreted as a relative match in the last
533 # set of matches found by ->_my_match eg
534  
535 # [p_tm_number => 1] means get the second match (from the last set of matches)
536 # and use it as the value of p_tm_number.
537  
538 # If the value is a array ref eg [p_tm_number, [0, sub { $_[0] .'Blah' }]
539 # then the query_string becomes p_tm_number => $ar->[1]( $name_vals{$ar->[0]} )
540  
541 # qs_fixed is an array_ref containing name value pairs
542  
543 9 my ($request, $content_type, @query_string, $query_string, @qs_var, @qs_fixed, %name_vals, @nvp);
544 9 my @matches = @{ $self->matches() };
545 9 @qs_var = @$qs_var_ar;
546 9 @qs_fixed = @$qs_fixed_ar;
547 9 %name_vals = %$name_vals_hr;
548  
549 # add the matches as (over the top if some of the name_val keys are eq '0', '1' ..) keys to %name_vals
550 9 @name_vals {0 .. $#matches} = @matches;
551 9 @query_string = ();
552 9 @nvp = ();
553 9 $query_string = '';
554 9 $content_type = 0; # 'application/x-www-form-urlencoded'
555  
556 9 ▶ while ( my ($name, $val) = splice(@qs_fixed, 0, 2) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@qs_fixed, 0, 2)) 0 9 9
557 0 splice(@query_string, scalar @query_string, 0, ($name, $val));
558 0 ▶ $content_type = 1 if ( ref $val eq 'ARRAY' );
Branch: 1 branch
BranchTrueFalseTotal
if ref $val eq "ARRAY" 0 0 0
559 }
560  
561 # a cgi var name must be in qs_var for it's value to be changed (otherwise it doesn't get in the form query string)
562  
563 9 ▶ while ( my ($name, $val) = splice(@qs_var, 0, 2) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@qs_var, 0, 2)) 0 9 9
564 0 ▶ @nvp = ref $val eq 'ARRAY' ? ( $name, &{ $val->[1] }($name_vals{$val->[0]}) ) : ( $name, $name_vals{$val} );
Branch: 1 branch
BranchTrueFalseTotal
ref $val eq 'ARRAY' ? : 0 0 0
565 0 splice ( @query_string, scalar @query_string, 0, @nvp );
566 }
567  
568 9 ▶ if ( $method eq 'GET' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($method eq 'GET') { } 9 0 9
elsif ($method eq 'POST') { } 0 0 0
elsif ($method eq 'HEAD') { } 0 0 0
569 0 ▶ while ( my ($name, $val) = splice(@query_string, 0, 2) ) { $query_string .= "$name=$val&"; }
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@query_string, 0, 2)) 0 9 9
570  
571 9 ▶ if ($query_string) {
Branch: 1 branch
BranchTrueFalseTotal
if ($query_string) { } 0 9 9
572 0 chop($query_string);
573 0 $request = GET $url .'?'. $query_string;
574 } else {
575 9 $request = GET $url;
576 }
577 } elsif ( $method eq 'POST' ) {
578 0 ▶ if ( $content_type == 1 ) { # 'multipart/form-data'
Branch: 1 branch
BranchTrueFalseTotal
if ($content_type == 1) { } 0 0 0
579 0 $request = POST $url, Content_Type => 'multipart/form-data', Content => [ @query_string ];
580 } else {
581 0 $request = POST $url, [ @query_string ];
582 }
583 } elsif ( $method eq 'HEAD' ) {
584 0 $request = HEAD $url;
585 } else { # do something to indicate no such method
586 0 &_dumpValue ( $self, ref $self .": Unexpected method \"$method\" for url \"$url\"" );
587 }
588 }
589  
590 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
591  
592 0 ▶sub _my_match {
Subroutine _my_match: not called CC=10 SCAR=47.0
593 0 my ($self, $pat, $str, $boolean) = @_;
594  
595 0 ▶ return $boolean if ( $str eq '' and ref $pat ne 'ARRAY' and $pat eq '...' );
Branch: 1 branch
BranchTrueFalseTotal
if $str eq "" and ref $pat ne "ARRAY" and $pat eq "..." 0 0 0
Condition0%0/6
$str eq "" and ref $pat ne "ARRAY" and $pat eq "..."
!ll&&!rl&&r
000
$str eq "" and ref $pat ne "ARRAY"
!ll&&!rl&&r
000
MC/DC0%0/3
$str eq "" and ref $pat ne "ARRAY" and $pat eq "..."
$str eq "" ref $pat ne "ARRAY" $pat eq "..."
Truth table0%0/4
A and B and C
A= $str eq ""B= ref $pat ne "ARRAY"C= $pat eq "..."
ABCresult
0XX0
10X0
1100
1111
596 0 my $found = 0;
597 0 my @matches = ();
598  
599 0 ▶ if ( ref $pat eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $pat eq 'ARRAY') { } 0 0 0
600 0 my $debug = ${$self->{asnmtapInherited}}->getOptionsValue ( 'debug' );
601  
602 0 foreach my $p (@$pat) {
603 0 ▶ print ref ($self) ."::_my_match: ? $p\n" if ( $debug >= 3 );
Branch: 1 branch
BranchTrueFalseTotal
if $debug >= 3 0 0 0
604  
605 0 ▶ if ( my @match = ($str =~ m#$p#) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@match) = $str =~ /$p/) 0 0 0
606 0 ▶ print ref ($self) ."::_my_match: = @match\n" if ( $debug >= 3 );
Branch: 1 branch
BranchTrueFalseTotal
if $debug >= 3 0 0 0
607 0 ▶ push (@matches, @match) if (scalar (@match));
Branch: 1 branch
BranchTrueFalseTotal
if scalar @match 0 0 0
608 0 $found++;
609 }
610 }
611  
612 0 $self->matches ( \@matches );
613 } else {
614 0 $found = ($str =~ m#$pat#);
615 }
616  
617 0 return $found;
618 }
619  
620 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
621  
622 0 ▶sub _my_return {
Subroutine _my_return: not called CC=7 SCAR=40.3
623 0 my ($self, $pat, $str) = @_;
624  
625 0 ▶ if ( ref $pat eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $pat eq "HASH") 0 0 0
626 0 my $debug = ${$self->{asnmtapInherited}}->getOptionsValue ( 'debug' );
627  
628 0 ▶ while ( my ($key, $value) = each ( %{$pat} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$pat;}) 0 0 0
629 0 ▶ print ref ($self) ."::_my_return: ? $key => $value\n" if ( $debug >= 3 );
Branch: 1 branch
BranchTrueFalseTotal
if $debug >= 3 0 0 0
630  
631 0 ▶ if ( my @match = ($str =~ m#$value#g) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(@match) = $str =~ /$value/g) { } 0 0 0
632 0 ▶ print ref ($self) ."::_my_return: = @match\n" if ( $debug >= 3 );
Branch: 1 branch
BranchTrueFalseTotal
if $debug >= 3 0 0 0
633 0 ▶ $returns {$key} = (scalar (@match) == 1) ? $match[0] : [ @match ];
Branch: 1 branch
BranchTrueFalseTotal
scalar @match == 1 ? : 0 0 0
634 } else {
635 0 $returns {$key} = undef;
636 }
637  
638 0 $self->returns ( \%returns );
639 }
640 }
641 }
642  
643 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
644  
645 0 ▶sub _write_debugfile {
Subroutine _write_debugfile: not called CC=4 SCAR=30.0
646 0 my ($self, $request_as_string, $response_as_content, $debugfile, $openAppend) = @_;
647  
648 0 ▶ my $rvOpen = open ( HTTPDUMP, ($openAppend ? '>>' : '>') .$debugfile );
Branch: 1 branch
BranchTrueFalseTotal
$openAppend ? : 0 0 0
649  
650 0 ▶ if ($rvOpen) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rvOpen) { } 0 0 0
651 0 print HTTPDUMP '<HR>', $request_as_string, "\n";
652  
653 0 ▶ if ( defined $response_as_content ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $response_as_content) { } 0 0 0
654 0 $response_as_content =~ s/(window.location.href)/\/\/$1/gi;
655  
656 # RFC 1738 -> [ $\/:;=?@.\-!*'()\w&+,]+
657 0 $response_as_content =~ s/(<META\s+HTTP-EQUIV\s*=\s*\"Refresh\"\s+CONTENT\s*=\s*\"\d+;\s*URL\s*=[^"]+\"(?:\s+\/?)?>)/<!--$1-->/img;
658  
659 # remove password from Basic Authentication URL before putting into database!
660 0 $response_as_content =~ s/(http[s]?)\:\/\/(\w+)\:(\w+)\@/$1\:\/\/$2\:********\@/img;
661  
662 # comment <SCRIPT></SCRIPT>
663 0 $response_as_content =~ s/<SCRIPT/<!--<SCRIPT/gi;
664 0 $response_as_content =~ s/<\/SCRIPT>/<\/SCRIPT>-->/gi;
665  
666 # replace <BODY onload="..."> with <BODY>
667 0 $response_as_content =~ s/<BODY\s*onload\s*=\s*.*\s*>/<BODY>/gi;
668  
669 0 print HTTPDUMP '<HR>', $response_as_content, "\n";
670 } else {
671 0 print HTTPDUMP "<HR><B>Empty response</B>\n";
672 }
673  
674 0 close(HTTPDUMP);
675 } else {
676 0 print ref ($self) .": Cannot open $debugfile to print debug information\n";
677 }
678 }
679  
680 # = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
681  
682 0 ▶sub _next_url {
Subroutine _next_url: not called CC=4 SCAR=30.0
683 0 my ($response, $response_as_content) = @_;
684  
685 # FIXME. Some applications (eg IIS module for SAP R3) have an action field relative to hostname.
686 # Others (eg ADDS v2) have use a refresh header with relative to hostname/path ..
687  
688 0 ▶ if ( $response_as_content =~ m#META\s+http-equiv="refresh"\s+content="\d+;\s+url=([^"]+)"# ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($response_as_content =~ /META\s+http-equiv="refresh"\s+content="\d+;\s+url=([^"]+)"/) { } 0 0 0
elsif ($response_as_content =~ /form name="[^"]+"\s+method="post"\s+action="([^"]+)"/i or $response_as_content =~ /form\s+method="post"\s+action="([^"]+)"/i) { } 0 0 0
689 0 my $rel_url = $1;
690 0 my $base = $response->base;
691 0 $base =~ m#(http://.+/).+?$#;
692 0 my $url = $1 . $rel_url;
693 0 return $url;
694 ▶ } elsif ( $response_as_content =~ m#form name="[^"]+"\s+method="post"\s+action="([^"]+)"#i or $response_as_content =~ m#form\s+method="post"\s+action="([^"]+)"#i ) {
Condition0%0/3
$response_as_content =~ /form name="[^"]+"\s+method="post"\s+action="([^"]+)"/i or $response_as_content =~ /form\s+method="post"\s+action="([^"]+)"/i
l!l&&r!l&&!r
000
MC/DC0%0/2
$response_as_content =~ /form name="[^"]+"\s+method="post"\s+action="([^"]+)"/i or $response_as_content =~ /form\s+method="post"\s+action="([^"]+)"/i
$response_as_content =~ /form name="[^"]+"\s+method="post"\s+action="([^"]+)"/i $response_as_content =~ /form\s+method="post"\s+action="([^"]+)"/i
Truth table0%0/3
A or B
A= $response_as_content =~ /form name="[^"]+"\s+method="post"\s+action="([^"]+)"/iB= $response_as_content =~ /form\s+method="post"\s+action="([^"]+)"/i
ABresult
1X1
011
000
695 # Attachmate eVWP product doesn't have a form name.
696 0 my $rel_url = $1;
697 0 my $base = $response->base;
698 0 $base =~ m#(http://.+?)/#; # only want hostname
699 0 my $url = $1 . $rel_url;
700 0 return $url;
701 } else {
702 0 return '';
703 }
704 }
705  
706 # Destructor - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
707  
708 6 ▶sub DESTROY {
Subroutine DESTROY: called CC=4 SCAR=15.2
709 6 ▶ print (ref ($_[0]), "::DESTROY: ()\n") if ( ${$_[0]->{asnmtapInherited}}->getOptionsValue ( 'debug' ) );
Branch: 1 branch
BranchTrueFalseTotal
if ${$_[0]{"asnmtapInherited"};}->getOptionsValue("debug") 0 6 6
710 6 ▶ rename ( $_[0]->{_KnownError}, $_[0]->{_KnownError} .'-KnownError' ) if ( defined $_[0]->{_KnownError} and ! $_[0]->{_unknownErrors} );
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[0]{"_KnownError"} and not $_[0]{"_unknownErrors"} 0 6 6
Condition33%1/3
defined $_[0]{"_KnownError"} and not $_[0]{"_unknownErrors"}
!ll&&!rl&&r
600
MC/DC0%0/2
defined $_[0]{"_KnownError"} and not $_[0]{"_unknownErrors"}
defined $_[0]{"_KnownError"} not $_[0]{"_unknownErrors"}
Truth table33%1/3
A and not(B)
A= defined $_[0]{"_KnownError"}B= not $_[0]{"_unknownErrors"}
ABresult
0X0
100
111
711 6 ${$_[0]->{asnmtapInherited}}->appendPerformanceData ( "'url timing retries'=". $_[0]->{_timing_tries} .';;;;' );
712 }
713  
714 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
715  
716 25 1;
717  
718 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
719  
720 __END__
« blib/lib/ASNMTAP/Asnmtap/Plugins/Modem.pm ↑ Summary blib/lib/ASNMTAP/Asnmtap/Applications/CGI.pm »