Future...tAsync(3pm)

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

πŸ’– Future::HTTP::NetAsync β€” the vibe ✨

okay bestie, so this page is Future...tAsync(3pm) from the User Contributed Perl Documentation, and it's about Future::HTTP::NetAsync β€” an asynchronous HTTP client that speaks Future. yes, it's giving main character energy. come sit with me 🫢


🌸 NAME 🌸

Future::HTTP::NetAsync β€” an asynchronous HTTP client with a Future interface πŸ’…


✨ DESCRIPTION ✨

This is the backend when running with IO::Async. It will execute the requests asynchronously. no blocking, no waiting around like a loser, the requests just go do their thing πŸ¦‹


πŸŽ€ METHODS πŸŽ€

πŸ’… Future::HTTP::NetAsync->new()

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

Creates a new instance of the HTTP client. that's it, that's the constructor, it's iconic for being simple πŸ’–

πŸ’… $ua->is_async()

Returns true, because this backend is asynchronous. like obviously, it's literally in the name bestie 😭

πŸ’… $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, like the function in AnyEvent::HTTP. so you get both the body and the headers, no cap πŸ‘‘

πŸ’… $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. heads up (pun fully intended, I'm hilarious): this one's the HEAD request 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. sending data out into the world, slay πŸ¦‹

πŸ’… $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 one where you pick the $method β€” yes, you, the main character ✨

okay important lil heads-up: Note that this subclass will automatically collect cookies. This may or may not be the behaviour you want. so like... it's out here hoarding cookies like it's a snack stash πŸ“, and that might be exactly what you want or it might absolutely Not be. decide accordingly, bestie πŸ™ˆ

πŸ‘€ SEE ALSO πŸ‘€

  • Future
  • AnyEvent::HTTP for the details of the API
  • Net::Async::HTTP for the backend

🌈 REPOSITORY 🌈

The public repository of this module is <https://github.com/Corion/future-http>. go star it, it's giving community πŸ’œ


🫢 SUPPORT 🫢

The public support forum of this module is <https://perlmonks.org/>. the monks are lowkey legendary, fr fr 🧚


πŸ’€ 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@cpan.org. found a bug? tell on it, don't suffer in silence 😭


πŸ‘‘ AUTHOR πŸ‘‘

Max Maischein "corion@cpan.org" β€” the icon behind all this πŸ’–


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


⭐ LICENSE ⭐

This module is released under the same terms as Perl itself. periodt πŸ’…


so yeah, that's the whole page bestie β€” documented by User Contributed Perl Documentation, running on perl v5.40.1, dated 2026-01-14 πŸŽ€ go forth and make asynchronous requests, you absolute legend 🌟

πŸ“¦ where this page comes from