Future...yEvent(3pm)

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

✨ Future...yEvent(3pm) ✨

okay so bestie, you opened the Future...yEvent(3pm) page from the User Contributed Perl Documentation collection?? good. taste. πŸ’… buckle up because we're talking about asynchronous HTTP and it's lowkey iconic.


πŸ¦‹ NAME πŸ¦‹

Future::HTTP::AnyEvent β€” an asynchronous HTTP client with a Future interface. fr fr that's the whole glow-up. ✨


🌸 DESCRIPTION 🌸

so here's the tea β˜•: this is the backend that gets picked for you if either AnyEvent.pm or AE.pm show up in %INC. like, the module peeks at what you already loaded and goes "oh bestie you already have AnyEvent? say less, I got you." πŸ‘‘

and then? it runs all your requests asynchronously using AnyEvent::HTTP. no cap. non-blocking queen behavior. πŸ’–


πŸŽ€ METHODS πŸŽ€

πŸ’œ Future::HTTP::AnyEvent->new()

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

makes you a shiny new instance of the HTTP client. that's it, that's the vibe. new ua, who dis. 🫢


πŸ’œ $ua->is_async()

returns true, because this backend is asynchronous, obviously. it's giving "yes I do be like that." 😌✨


πŸ’œ $ua->http_get($url, %options)

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

goes and retrieves the URL, then hands you back the body and the headers β€” exactly like the function in AnyEvent::HTTP does. then you .then(...) your lil callback and live your life. πŸ”₯


πŸ’œ $ua->http_head($url, %options)

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

same energy but for the header of the URL β€” it retrieves the headers and returns them, like the function in AnyEvent::HTTP. no body, we're just peeking bestie. πŸ™ˆ


πŸ’œ $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. sending data out into the world, main character energy. πŸ’Œ


πŸ’œ $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. this is the flexible one β€” you pass whatever $method you want ('PUT' in the example) and it handles it. periodt. 🎯


πŸ‘€ SEE ALSO πŸ‘€

  • Future
  • AnyEvent::HTTP β€” for the details of the API

iykyk, go read those if you want the full lore. πŸ“š


🏠 REPOSITORY 🏠

the public repository of this module lives at <https://github.com/Corion/future-http>. go star it, it's free bestie. ⭐


🫢 SUPPORT 🫢

the public support forum of this module is at <https://perlmonks.org/>. the monks are lovely, they'll help you out. πŸ’–


πŸ› 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. found a bug? don't be shy, tell them, they wanna know. πŸ¦‹


πŸ‘‘ AUTHOR πŸ‘‘

Max Maischein "corion@cpan.org" β€” legend behavior honestly. ✨


Copyright 2016-2024 by Max Maischein "corion@cpan.org". πŸ’–


🌈 LICENSE 🌈

this module is released under the same terms as Perl itself. slay. πŸŽ€


and that's the whole page!! perl v5.40.1, dated 2026-01-14, straight from the Future...yEvent(3pm) manual β€” you're all caught up bestie, now go make some async requests and thrive. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from