Future...::Tiny(3pm)

πŸ“¦
version 0.17 Β· 4 versions
, in ubuntu resolute, ubuntu stonking

✨ NAME ✨

Future::HTTP::Tiny β€” bestie, it's a synchronous HTTP client that still hands you a Future interface, like a little gift 🎁. That's the whole vibe: sync under the hood, future-shaped on top. πŸ’…

It's a 3pm manual page, so consider this the group chat where we spill all the tea about it. πŸ«–


🌸 DESCRIPTION 🌸

Okay so listen: this is the default backend. The way this works is, if no supported event loop could be detected, you get this one. Periodt. ✨

And because there's no event loop to play with, it just executes the requests synchronously as they're made inside ->http_request. No async shenanigans, no waiting around for the loop to wake up β€” it just does the thing right then. πŸ’€


πŸ’– METHODS πŸ’–

πŸ¦‹ Future::HTTP::Tiny->new()

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

Creates a brand new instance of the HTTP client. Your shiny new $ua, slay. πŸ‘‘

πŸŽ€ $ua->is_async()

Returns false, because this backend is synchronous. That's it, that's the whole function β€” it's giving honesty. It's not async, it never claimed to be async, and it's not about to lie to you. πŸ’…

πŸ“ $ua->http_get($url, %options)

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

Retrieves the URL and hands you back the body and the headers, just like the function does in AnyEvent::HTTP. Then ->then gets called with $body and $headers and you can go off. πŸ”₯

🌈 $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, matching the function in AnyEvent::HTTP. Same API energy, different verb. ✨

🧚 $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, again exactly like the function in AnyEvent::HTTP. Sending the payload, 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 β€” yep, like the function in AnyEvent::HTTP. This is the one where you pick your own $method, so it's giving main character energy. 🌟


πŸ’œ COMPATIBILITY πŸ’œ

HTTP::Tiny is genuinely a good backend because it ships with, like, so many versions of Perl. Built in, no extra install, iconic. 🎁

But β€” and this is the plot twist 😭 β€” the drawback is that not all versions of HTTP::Tiny support all features. The following features are simply unsupported on older versions of HTTP::Tiny:

  • ->{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. πŸ’€

So if you're on an ancient HTTP::Tiny and wondering why those keys are ghosting you, that's why. iykyk.


πŸ”₯ SEE ALSO πŸ”₯

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

Go read those if you want the full picture, bestie. πŸ“š


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

Bestie, if something's broken, tell the maintainers, don't suffer in silence. πŸ₯Ί

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


And that's the whole page, fr fr πŸŽ€ β€” written for perl v5.40.1, dated 2026-01-14, and catalogued as Future::HTTP::Tiny(3pm). Thanks for reading this far, bestie, you ate. πŸ’…βœ¨

πŸ“¦ where this page comes from