NAME

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

SYNOPSIS

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

# where to cache DNS lookup results
HTTP::LoadGen::Run::dnscache=\%cache;

# 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.

HTTP::LoadGen::Run::dnscache

an lvalue function that allows to set/get a hash where DNS lookup results are cached.

HTTP::LoadGen::Run::register_no_response_body_method $method

register a new HTTP method that is expected to not send a response body by default. Normally, HEAD is the only one that shows that behavior.

HTTP::LoadGen::Run::delete_no_response_body_method $method

delete a method from the set that do not send a response body.

HTTP::LoadGen::Run::register_no_response_body_code $http_code

register a new HTTP status code that is known to not include a response body by default. Normally, 1xx, 204 and 304 show that behavior.

HTTP::LoadGen::Run::delete_no_response_body_code $http_code

delete a HTTP status code from the set that do not include a response body.

$no_body=HTTP::LoadGen::Run::no_response_body $http_code, $method

asks if a pair of HTTP status and request method is expected to include a response body.

returns true if the body is omitted.

HTTP::LoadGen::Run::conncache

the cache of kept-alive connections. Returns a hash ref.

HTTP::LoadGen::Run::build_req

internal use.

HTTP::LoadGen::Run::config_handle

internal use.

HTTP::LoadGen::Run::gen_cb

internal use.

HTTP::LoadGen::Run::readEOF

internal use.

HTTP::LoadGen::Run::readchunk

internal use.

HTTP::LoadGen::Run::readchunked

internal use.

HTTP::LoadGen::Run::readln

internal use.

HTTP::LoadGen::Run::tlscache

internal use, experimental.

HTTP::LoadGen::Run::tlsctx

internal use, experimental.

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.