Future...ranoid(3pm)

๐Ÿ“ฆ
version 0.17 ยท 4 versions
, in ubuntu resolute, ubuntu stonking

๐Ÿ’– NAME ๐Ÿ’–

ok so bestie, meet Future::HTTP::Tiny::Paranoid โ€” a synchronous HTTP client that still hands you a Future interface, because we can have both. it's giving "I do it all in order but I still make it look async" โœจ


๐ŸŒธ DESCRIPTION ๐ŸŒธ

This one's the default backend, okay? It gets picked when no supported event loop could be detected. And when it gets picked, it does the thing synchronously โ€” like, each request runs right as you make it in ->http_request. no waiting around, no event loop drama, it just goes ๐Ÿซถ

๐ŸŽ€ Whitelist / Blacklist ๐ŸŽ€

You can set up the whitelist and blacklist through the global accessors, queen:

# Allow access to localhost
HTTP::Tiny::Paranoid->whitelisted_hosts([ 'localhost', '127.0.0.1' ]);

# Deny access to localhost
HTTP::Tiny::Paranoid->blacklisted_hosts([ 'localhost', '127.0.0.1' ]);

โœจ METHODS โœจ

"Future::HTTP::Tiny::Paranoid->new()"

my $ua = Future::HTTP::Tiny::Paranoid->new();

Creates a new instance of the HTTP client. brand new baby, fresh out the box ๐Ÿ’…

"$ua->is_async()"

Returns false, because this backend is synchronous. it's an honest queen, she tells you exactly what she is. ๐Ÿ™ˆ

"$ua->http_get($url, %options)"

$ua->http_get('http://example.com/',
    headers => {
        'Accept' => 'text/json',
    },
)->then(sub {
    my( $body, $headers ) = @_;
    ...
});

Retrieves the URL and returns the body and headers, exactly like the function in AnyEvent::HTTP. the then block eats ($body, $headers) and off you go ๐Ÿฆ‹

"$ua->http_head($url, %options)"

$ua->http_head('http://example.com/',
    headers => {
        'Accept' => 'text/json',
    },
)->then(sub {
    my( $body, $headers ) = @_;
    ...
});

Retrieves the header of the URL and returns the headers, like the function in AnyEvent::HTTP. yeah we still hand you both slots in the callback, that's just the vibe ๐Ÿ˜Œ

"$ua->http_post($url, $body, %options)"

$ua->http_post('http://example.com/api',
    '{token:"my_json_token"}',
    headers => {
        'Accept' => 'text/json',
    },
)->then(sub {
    my( $body, $headers ) = @_;
    ...
});

Posts the content to the URL and returns the body and headers, like the function in AnyEvent::HTTP. send it, bestie ๐Ÿ“ฎ

"$ua->http_request($method, $url, %options)"

$ua->http_request('PUT' => 'http://example.com/api',
    headers => {
        'Accept' => 'text/json',
    },
    body    => '{token:"my_json_token"}',
)->then(sub {
    my( $body, $headers ) = @_;
    ...
});

Posts the content to the URL and returns the body and headers, like the function in AnyEvent::HTTP. yes this one also says "posts" in the description even though you can pass any method โ€” we don't make the rules, we just keep the facts exactly as they are ๐Ÿ’€


๐ŸŒˆ COMPATIBILITY ๐ŸŒˆ

HTTP::Tiny is a good backend because it is distributed with many versions of Perl. the drawback? not all versions of HTTP::Tiny support all features. here's what's unsupported on older versions:

  • "->{URL}" โ€” HTTP::Tiny versions before 0.018 didn't tell about 30x redirections.
  • "->{redirects}" โ€” HTTP::Tiny versions before 0.058 didn't record the chain of redirects.
bestie pls note the version numbers, they're doing heavy lifting here ๐Ÿซถ

๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘

  • Future
  • AnyEvent::HTTP for the details of the API

๐Ÿงš REPOSITORY ๐Ÿงš

The public repository of this module is <https://github.com/Corion/future-http>.


๐Ÿ“ SUPPORT ๐Ÿ“

The public support forum of this module is <https://perlmonks.org/>.


๐Ÿ’œ BUG TRACKER ๐Ÿ’œ

Please report bugs in this module via the RT CPAN bug queue at <https://rt.cpan.org/Public/Dist/Display.html?Name=Future-HTTP> or via mail to future-http-Bugs@rt.cpan.org.


โญ AUTHOR โญ

Max Maischein "corion@cpan.org"


Copyright 2016-2024 by Max Maischein "corion@cpan.org".


๐Ÿ’… LICENSE ๐Ÿ’…

This module is released under the same terms as Perl itself.


ok that's the whole page, no cap ๐Ÿ’– this was the Future...ranoid(3pm) page from User Contributed Perl Documentation, and the sign-off says perl v5.40.1, dated 2026-01-14 โ€” slay, go make those requests ๐Ÿฆ‹โœจ

๐Ÿ“ฆ where this page comes from