ASNMTAP
view release on metacpan or search on metacpan
lib/ASNMTAP/Asnmtap/Plugins/WebTransact.pod view on Meta::CPAN
In the latter case, the integer will be used as an index of the array of matches found from the
last set of patterns with memory (specified by the Exp field). So [ cgi_var_name => 0 ] leads to
a query string cgi_var_name = <the_first_match_in_the_set_of_Exp_patterns>
=over 4
=item *
an array ref of the form [ match_index => code_ref ]
In this case, the subroutine referred to by coderef is a subroutine with one parameter and it will be called with that parameter set to the first element in the array (the index of a former match). One may choose to do this with very dynamic web syst...
An example may make this more comprehensible !
use constant CmrDetailPat => [ qw( name="addr1_data-name1\[1\]"\s+value="(.*?)" ) ];
use constant Stars => '*' x 8;
my $star_pat = quotemeta( Stars ) . '$';
use constant AddStars_to_Name => [ 'addr1_data-name1[1]' => [0, sub { $_[0] . Stars }] ];
use constant DelStars_from_Name => [ 'addr1_data-name1[1]' => [0, sub { $_[0] =~ s#$star_pat##; $_[0] }] ];
If 'CmrDetailPat' is used as an Exp field, then a subsequent GET or POST can make use of
Qs_var values 'AddStars_to_Name' and 'DelStars_from_Name' to either append some asterisks to the value of the
web form name addr1_data-name1[1] or remove the stars.
=back
In this case, the subroutine referred to by coderef is a subroutine with one parameter and it will be
called with that parameter set to the first element in the array (the index of a former match).
One may choose to do this with very dynamic web systems such as the SAP R3 module for IIS in which the
CGI names and values may need to be dragged out of former responses.
Is an array reference containing the name value pairs of any parameters whose value is known only at run time.
The format is [ cgi_parm_name => val_at_run_time, ... ] where cgi_parm_name is the name of a fill out form parameter and val_at_run_time is a string used as a key to get the value of the cgi parameter.
Qs_var = [ form_name_1 => 0, form_name_2 => 1 ..] will lead to a query_string like
form_name_1 = $matches[0], form_name_2 = $matches[1] ... in $self->_make_req() by
@matches = $self->matches() and using 0, 1 etc as indices of @matches.
=item Qs_fixed
B<Qs_fixed> contains the name value pairs that are known at compile time whereas.
Is an array reference containing name value pairs.
The format is [ cgi_var_name => val, ... ] where cgi_var_name is the name of a fill out form parameter and val is a string with the value of the cgi parameter
=item Exp .
B<Exp> is the pattern that when matched against the respose to the URL (in the same hash) indicates success.
Is an scalar (value is a string) or an array
$objectWebTransact->matches() will updated with the set of matches it finds by matching
patterns with memory (ie patterns in paren) from the Exp field against the request response.
=item Exp_Fault
B<Exp_Fault> is the pattern that indicates the response is a failure.
If these patterns contain parentheses eg 'match a lot (.*)', then the match is saved for use by
Qs_var. Note that there should be only B<one> pattern per element of the Exp list. Nested patterns
( C<yada(blah(.+)blurble(x|y|zz(top.*))> ) will not work as expected.
Is an scalar (value is a string), ex. blurb
=item Exp_Return
B<Exp_Return> is the pattern that indicates the response is a return.
Is an hash, { var_label_1 => EXP_VAR_LABEL_1, ... }
=item Msg .
This message is added to the error field when not all Exp found.
Is an scalar (value is a string), ex. 'Status error when not all Exp found'
=item Msg_Fault
This message is added to the error field when Exp_Fault found.
Is an scalar (value is a string), ex. 'Status error when Exp_Fault found'
=item Timeout
This means that for this URL the specified timeout will be used.
Is an scalar (value is a integer greater then 0), ex. 30
=item Perfdata_Label
This means that for this URL there performance data will be created and the name for the label equals the value from Perfdata_Label.
Is an scalar (value is a string), ex. 'Label x'
=back
I<Example:>
use ASNMTAP::Asnmtap::Plugins::WebTransact;
my @URLS = (
{ Method => 'GET', Url => 'http://www.citap.be/', Qs_var => [], Qs_fixed => [], Exp => "Consulting Internet Technology Alex Peeters", Exp_Fault => ">>>NIHIL<<<", Msg => "Consulting Internet Technology Alex Peeters", Msg_Fault => "Consulting Inte...
);
my $objectWebTransact = ASNMTAP::Asnmtap::Plugins::WebTransact->new ( \$objectPlugins, \@URLS );
equals to:
use ASNMTAP::Asnmtap::Plugins::WebTransact;
my @URLS = ();
my $objectWebTransact = ASNMTAP::Asnmtap::Plugins::WebTransact->new ( \$objectPlugins, \@URLS );
@URLS = (
{ Method => 'GET', Url => 'http://www.citap.be/', Qs_var => [], Qs_fixed => [], Exp => "Consulting Internet Technology Alex Peeters", Exp_Fault => ">>>NIHIL<<<", Msg => "Consulting Internet Technology Alex Peeters", Msg_Fault => "Consulting Inte...
);
$objectWebTransact->urls( \@URLS );
lib/ASNMTAP/Asnmtap/Plugins/WebTransact.pod view on Meta::CPAN
return ( $ERRORS{OK}, 0, undef );
}
}
Is an scalar, reference to a function, default: undef
=item I<perfdataLabel>
set the performancedata label for a group of URLs
=over 4
=item I<Example>
my @URLS = (
{ Method => 'GET', Url => 'http://www.citap.be/', Qs_var => [], Qs_fixed => [], Exp => "Consulting Internet Technology Alex Peeters", Exp_Fault => ">>>NIHIL<<<", Msg => "Consulting Internet Technology Alex Peeters", Msg_Fault => "Consulting Inte...
{ Method => 'GET', Url => 'http://www.citap.com/', Qs_var => [], Qs_fixed => [], Exp => "Consulting Internet Technology Alex Peeters", Exp_Fault => ">>>NIHIL<<<", Msg => "Consulting Internet Technology Alex Peeters", Msg_Fault => "Consulting Int...
);
$returnCode = $objectWebTransact->check ( { }, custom => \&customWebTransact, perfdataLabel => 'homepage' );
equals to:
my @URLS = (
{ Method => 'GET', Url => 'http://www.citap.be/', Qs_var => [], Qs_fixed => [], Exp => "Consulting Internet Technology Alex Peeters", Exp_Fault => ">>>NIHIL<<<", Msg => "Consulting Internet Technology Alex Peeters", Msg_Fault => "Consulting Inte...
{ Method => 'GET', Url => 'http://www.citap.com/', Qs_var => [], Qs_fixed => [], Exp => "Consulting Internet Technology Alex Peeters", Exp_Fault => ">>>NIHIL<<<", Msg => "Consulting Internet Technology Alex Peeters", Msg_Fault => "Consulting Int...
);
$startTime = $objectPlugins->setEndTime_and_getResponsTime ( $objectPlugins->pluginValue ('endTime') );
$returnCode = $objectWebTransact->check ( { }, custom => \&customWebTransact );
$responseTime = $objectPlugins->setEndTime_and_getResponsTime ( $startTime );
$objectPlugins->appendPerformanceData ( 'homepage='. $responseTime .'ms;'. ($trendline*1000) .';;;' );
=back
=item I<newAgent>
The first time we call $objectWebTransact->check ( { }, ... ),
is an scalar, value is 0, 1 or undef (default)
undef: current (browser) session will be used, but at the first
all a new (browser) session will automaticallybe created
0 : current (browser) session will be used
1 : new (browser) session will be created
This means that when you specify newAgent => 0 the first time you call $objectWebTransact->check, it will be treated as newAgent => 1, to ensure that an (browser) session is created.
Every time whel for a following call $objectWebTransact->check ( { }, ... ), newAgent equals 1, then a new (browser) session is created.
When newAgent equals 0, then we using the same (browser) session again.
Optional, is an scalar, value is 0 or 1
=item I<timeout>
Every time we call $objectWebTransact->check ( { }, timeout => 30, ... ),
is an scalar, value greater then 0 or undef (default)
When timeout equals undef, then we using the timeout from the parent object.
Optional, is an scalar, value is greater the 0
=item I<triesTiming>
Every time we call $objectWebTransact->check ( { }, triesTiming => '1,3,15', ... ), to get a web page and run into a possibly-temporary error (like a DNS lookup timeout), it'll wait a few seconds and retry a few times.
is an string that controls how many times it should retry, and how long the pauses should be, values greater then 0 separated by a ',' or undef (default)
When triesTiming equals undef or an empty-string, this means not to retry at all.
If you specify a string with several numbers in it (like '1,3,15'), then that means WebTransact can retry as that many times (i.e., one initial try, plus a maximum of the three retries, because three numbers there), and that it should wait first thos...
So triesTiming => '1,3,15' basically means:
try the request; return it unless it's a temporary-looking error;
sleep 1;
retry the request; return it unless it's a temporary-looking error;
sleep 3;
retry the request; return it unless it's a temporary-looking error;
sleep 15;
retry the request; return it;
=item I<triesCodes>
Is an string of HTTP codes that merit a retry (like 500 and 408, but unlike 404 or 200), values greater then 200 separated by a ',' or '408,500,502,503,504' (default).
408 Request Timeout: The client did not send a request within the required time period
500 Can't connect to ..., Connect failed, Proxy connect failed, Server Error, SSL negotiation failed, SSL read timeout or Internal Server Error: The server had some sort of internal error trying to fulfil the request. The client may see a partial p...
502 Bad Gateway: Bad Gateway: a server being used by this Web server has sent an invalid response. The response by an intermediary server was invalid. This may happen if there is a problem with the DNS routing tables.
503 Service Unavailable: Service temporarily unavailable because of currently/temporary overload or maintenance.
504 Gateway Timeout: The server did not respond back to the gateway within acceptable time period
=item I<openAppend>
Is an scalar, open debugfile as 'Writes, Appends, and Creates' mode when 1, otherwise open debugfile in 'Creates, Writes, and Truncates' mode.
=item I<cookies>
Is an scalar, value is 0 or 1 (default)
=item I<protocol>
0 = default and 1 = force 'HTTP/1.1'
Is an scalar, value is 0 or 1 (default)
=item I<keepAlive>
0 = default and 1 = 'Keep-Alive'
Is an scalar, value is 0 or 1 (default)
=item I<download_images>
get the images found by HTML::LinkExtor in the page, provided those images have not already been ed.
( run in 0.575 second using v1.01-cache-2.11-cpan-39bf76dae61 )