NAME
Langertha::HTTP::ConnectCheck - Check that the modules Net::Async::HTTP loads at connect time load
VERSION
version 0.503
SYNOPSIS
use Langertha::HTTP::ConnectCheck;
if ( my $error = Langertha::HTTP::ConnectCheck::connect_error( $request->uri ) ) {
return Future->fail( "$class: $error\n", 'connect' );
}
return $net_async_http->do_request( request => $request );
DESCRIPTION
Internal module. Its interface may change without notice.
Net::Async::HTTP loads some modules only when it opens a connection: IO::Async::Internals::Connector for every connection, IO::Async::SSL (with IO::Socket::SSL, Net::SSLeay and the system's libssl) for https. When such a load dies, Net::Async::HTTP 0.50 has already counted the connection against the host, and the dead connection keeps the host's slot: every later request to that host waits forever, even once the module loads (max_connections_per_host is one by default). Core asks this module before it hands a request to a Net::Async::HTTP client (Langertha::Role::AsyncHTTP, Langertha::Content::Image), so a broken install is an error that names the module instead of a hang (karr k353).
connect_error
my $error = Langertha::HTTP::ConnectCheck::connect_error( $uri );
my $error = Langertha::HTTP::ConnectCheck::connect_error( $uri, $ssl ); # an explicit SSL option
Returns undef when the modules a connection to $uri (a URI or a string) needs load, else a one-line message without a trailing newline: cannot connect to <scheme>://<host>:<port>: <module> failed to load (<first line of the load error>); <why it is needed>. Only scheme, host and port name the target: a query or userinfo may carry a key.
Whether the connection needs SSL follows Net::Async::HTTP 0.50: a SSL request option, passed here as $ssl, wins when given (_do_request puts the caller's options after the SSL it derives from the scheme), so http with SSL => 1 connects with SSL and https with SSL => 0 without; otherwise the scheme decides (https is SSL).
A module that loads is not loaded again (perl keeps it in %INC), so once the modules are in, the check costs a few microseconds per request.
IO::Async::Internals::Connector is a private module name of IO::Async, hard-coded here on the assumption that IO::Async::Loop keeps loading it lazily under that name on connect (true for IO::Async 0.805). If IO::Async renames it, the check reports a module that cannot load on every request, and this module must follow the rename. The whole check can go once Net::Async::HTTP releases the host's slot when a connect-time load dies.
SUPPORT
Issues
Please report bugs and feature requests on GitHub at https://github.com/Getty/langertha/issues.
IRC
Join #langertha on irc.perl.org or message Getty directly.
CONTRIBUTING
Contributions are welcome! Please fork the repository and submit a pull request.
AUTHOR
Torsten Raudssus <getty@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2026 by Torsten Raudssus https://raudssus.de/.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.