IO::Lam...:Client(3)
π¦ NAME π¦
Welcome to the IO::Lam...:Client(3) page, bestie β straight from the User Contributed Perl Documentation. This one is all about IO::Lambda::HTTP::Client - http requests lambda style. obsessed π
πΈ DESCRIPTION πΈ
okay so this module exports exactly one condition: http_request. It accepts a HTTP::Request object and a set of options as parameters. The condition returns either a HTTP::Response on success, or an error string otherwise. no cap β¨
π SYNOPSIS π
hereβs the vibe check, copy this energy:
use HTTP::Request;
use IO::Lambda qw(:all);
use IO::Lambda::HTTP::Client qw(http_request);
lambda {
context shift;
http_request {
my $result = shift;
if ( ref($result)) {
print "good: ", length($result-> content), " bytes\n";
} else {
print "bad: $result\n";
}
}
}-> wait(
HTTP::Request-> new( GET => "http://www.perl.com/")
);
π API π
http_request $HTTP::Request -> $HTTP::Responseβhttp_requestis a lambda condition that accepts aHTTP::Requestobject in the context. Returns either aHTTP::Responseobject on success, or an error string otherwise. periodt π«Άnew $HTTP::Request :: () -> $HTTP::Responseβ Stores aHTTP::Requestobject and returns a new lambda that will finish when the associated request completes. The lambda will return either aHTTP::Responseobject on success, or an error string otherwise. main character energy fr fr π
β¨ OPTIONS β¨
async_dns BOOLEANβ If set, hostname will be resolved with IO::Lambda::DNS using asynchronous capabilities of Net::DNS. Note that this method won't be able to account for non-DNS (/etc/hosts, NIS) host names. If unset (default), hostnames will be resolved in a blocking manner. π¦auth $AUTHβ Normally, a request is sent without any authentication. If the request returns error 401, then all available methods of authentication are tried. If the type of authentication that shall be accepted by the remote is known in advance, the non-authenticated request stage can be skipped altogether by explicitly setting theauthoption:
username => 'user',
password => 'pass',
auth => 'Basic',
iykyk π
conn_cache $LWP::ConnCache = undefβ The requestor can optionally use aLWP::ConnCacheobject to reuse connections on per-host per-port basis. Desired for HTTP/1.1. Required for the NTLM/Negotiate authentication. See LWP::ConnCache for details. πcookie_jar $HTTP::Cookies = {}β The requestor can optionally use a sharedHTTP::Cookiesobject to support cookies. If not set, a local cookie jar is created and used for eventual redirects. To disable that, setcookie_jarto 0. See HTTP::Cookies for details. πdeadline SECONDS = undefβ Aborts a request and returns'timeout'string as an error if the request is not finished before the deadline (in epoch seconds). If undef, timeout never occurs. she will not wait forever, bestie β°keep_alive BOOLEANβ If set, all incoming request objects are silently converted to use HTTP/1.1, and connections are automatically reused. Same as combination of the following:
$req-> protocol('HTTP/1.1');
$req-> headers-> header( Host => $req-> uri-> host);
new( $req, conn_cache => LWP::ConnCache-> new);
slay π₯
max_redirect NUM = 7β Maximum allowed redirects. If 0, no redirection attempts are made. we are NOT going in circles forever πpreferred_auth $AUTH|%AUTHβ Sets list of preferred authentication methods, that is used in selection of the authentication method when the remote server supports several. When the value is a string, then the given method is tried first, and only then all other available methods. When it is a hash, the hash values are treated as weight factors, such as, the method with the greatest weight is tried first. Negative values prevent the corresponding methods from being tried.
# try basic and whatever else
preferred_auth => 'Basic',
# try basic and never ntlm
preferred_auth => {
Basic => 1,
NTLM => -1,
},
Note that the current implementation does not provide re-trying of authentication if a method, or combination of username and password fails. When at least one method is declared by the remote as supported, and was tried, and subsequently failed, no further authentication retries are made, and the request is reported as failed. oof, thatβs the rule fr fr π
proxy HOSTNAME | [ HOSTNAME, PORT ]β If set, HOSTNAME (or HOSTNAME and PORT tuple) is used as HTTP proxy. If set to undef, proxy is not used. If unset, the proxy is set automatically after content of environment variablesall_proxy,http_proxy,https_proxy,no_proxy. the environment said what it said πtimeout SECONDS = undefβ Maximum allowed time the request can take. If undef, no timeouts occur. set a limit or live dangerously, your call β
π BUGS π
Non-blocking connects, and hence the module, don't work on win32 on perl5.8.X due to under-implementation in ext/IO.xs. They do work on 5.10 however. not me reading this twice π
π§ SEE ALSO π§
IO::LambdaHTTP::RequestHTTP::Response
go read those too, bestie π
π AUTHOR π
Dmitry Karasik, <dmitry@karasik.eu.org>. π«Ά
okay thatβs the whole page, bestie π this was perl v5.42.2, dated 2026-02-15, signing off from IO::Lam...:Client(3) β mwah π
π¦ where this page comes from
- alpine 3.24: perl-io-lambda-doc 1.34-r1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms