The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

HTTP::LoadGen::Run - HTTP client for HTTP::LoadGen

SYNOPSIS

 BEGIN {$ENV{HTTP__LoadGen__Run__dbg}=1} # turn on debugging
 use HTTP::LoadGen::Run;

 # fetch an URL
 $rc=HTTP::LoadGen::Run::run_url $method, $scheme, $host, $port, $uri, $param;

 # fetch a list of URLs
 HTTP::LoadGen::Run::run_urllist +{times=>10,
                                   before=>sub {...},
                                   after=>sub {...},
                                   InitURLs=>sub {...}};

DESCRIPTION

HTTP::LoadGen::Run implements the HTTP client for HTTP::LoadGen.

Functions

$rc=HTTP::LoadGen::Run::run_url $method, $scheme, $host, $port, $uri, $param

performs one HTTP request as specified by the parameters. See URLList in HTTP::LoadGen for more information on the parameters.

Note, predelay and postdelay specifications are evaluated by HTTP::LoadGen::loadgen(). So, they don't have any effect here.

HTTP::LoadGen::Run::run_urllist \%config

performs a set of HTTP requests one at a time using run_url. %config is a hash that may contain these keys:

InitURLs

The value is an iterator generator as described in InitURLs in HTTP::LoadGen.

This value must be a code reference. There are no predefined iterators here.

times

see times in HTTP::LoadGen.

before

an optional code reference called as

 $config->{before}->($rq);

before each request. The ReqStart hook in HTTP::LoadGen is implemented this way.

after

an optional code reference called as

 $config->{before}->($rc, $rq);

after each request. The ReqDone hook in HTTP::LoadGen is implemented this way.

dnscache

see dnscache in HTTP::LoadGen.

EXPORT

All of the following constants are exported by default. See also HTTP::LoadGen.

Keep-Alive specification

KEEPALIVE_USE (1)

it is permitted to use a kept-alive connection if available

KEEPALIVE_STORE (2)

it is permitted to keep the connection alive for later usage

KEEPALIVE (3)

both of the above

Request descriptor

These constants are indices into an array returned by the URL iterator.

RQ_METHOD (0)

the HTTP request method, GET, POST, etc.

RQ_SCHEME (1)

http or https.

RQ_HOST (2)

the hostname or IP address

RQ_PORT (3)

the port number

RQ_URI (4)

the URI.

RQ_PARAM (5)

the $param hash.

Result elements

These constants are indices into the array returned by run_url.

RC_STATUS (0)
RC_STATUSLINE (1)
RC_HTTPVERSION (2)
RC_STARTTIME (3)
RC_CONNTIME (4)
RC_FIRSTTIME (5)
RC_HEADERTIME (6)
RC_BODYTIME (7)
RC_HEADERS (8)
RC_BODY (9)
RC_DNSCACHED (10)
RC_CONNCACHED (11)

see "Request descriptor and return element" in HTTP::LoadGen.

SEE ALSO

HTTP::LoadGen

AUTHOR

Torsten Förtsch, <torsten.foertsch@gmx.net>

COPYRIGHT AND LICENSE

Copyright (C) 2010 by Torsten Förtsch

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.