IO::Lam...:Client(3)

πŸ“¦ version 1.34, in alpine 3.24

πŸ¦‹ 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_request is a lambda condition that accepts a HTTP::Request object in the context. Returns either a HTTP::Response object on success, or an error string otherwise. periodt 🫢
  • new $HTTP::Request :: () -> $HTTP::Response β€” Stores a HTTP::Request object and returns a new lambda that will finish when the associated request completes. The lambda will return either a HTTP::Response object 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 the auth option:
username => 'user',
password => 'pass',
auth     => 'Basic',

iykyk πŸ’…

  • conn_cache $LWP::ConnCache = undef β€” The requestor can optionally use a LWP::ConnCache object 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 shared HTTP::Cookies object to support cookies. If not set, a local cookie jar is created and used for eventual redirects. To disable that, set cookie_jar to 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 variables all_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::Lambda
  • HTTP::Request
  • HTTP::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