Future::HTTP(3pm)
π Future::HTTP π
okay bestie, so this is Future::HTTP β from the User Contributed Perl Documentation crew (that's the manual it lives in, iykyk) β and it's literally the β¨most appropriateβ¨ HTTP client with a Future API. no cap.
πΈ NAME πΈ
Future::HTTP β provide the most appropriate HTTP client with a Future API π
β¨ SYNOPSIS β¨
my $ua = Future::HTTP->new();
my $res = $ua->http_get('http://www.nethype.de/')->then(sub {
my( $body, $data ) = @_;
# ... handle the response
return $body
})->get();
So here's the tea π«: this module is a wrapper that smashes Future together with the API that AnyEvent::HTTP gives you. and which backend actually ends up handling your HTTP protocols? that depends entirely on whether one of the event loops is loaded. it picks for you. main character energy, honestly. π
π¦ Supported event loops π¦
as of right now, these are the backends that get support:
HTTP::TinyHTTP::Tiny::ParanoidMojoliciousAnyEventIO::Async
and support is planned for LWP::UserAgent and POE, but it has not materialized yet π (they're on the vision board, not in the codebase, fr fr).
π METHODS π
π
Future::HTTP->new()
my $ua = Future::HTTP->new();
Creates a brand new instance of the HTTP client. fresh out the box, obsessed. β¨
π $ua->is_async()
Returns true if the backend that got selected is asynchronous, and false if it's synchronous. tiny little vibe check for your backend. π
π $ua->http_get($url, %options)
my $res = $ua->http_get('http://example.com/',
headers => {
'Accept' => 'text/json',
},
)->then(sub {
my( $body, $headers ) = @_;
# ... handle the response
})->get;
Retrieves the URL and hands you back the body and the headers, exactly like the function in AnyEvent::HTTP does it. π«Ά
π§ $ua->http_head($url, %options)
my $res = $ua->http_head('http://example.com/',
headers => {
'Accept' => 'text/json',
},
)->then(sub {
my( $body, $headers ) = @_;
...
})->get;
Retrieves the header of the URL and returns the headers, like the function in AnyEvent::HTTP. yes, just like that. no notes. π
β $ua->http_post($url, $body, %options)
my $res = $ua->http_post('http://example.com/api',
'{token:"my_json_token"}',
headers => {
'Accept' => 'text/json',
},
)->then(sub {
my( $body, $headers ) = @_;
...
})->get;
Posts the content to the URL and returns the body and headers, like the function in AnyEvent::HTTP. slay. π₯
πΈ $ua->http_request($method, $url, %options)
my $res = $ua->http_request('PUT' => 'http://example.com/api',
headers => {
'Accept' => 'text/json',
},
body => '{token:"my_json_token"}',
)->then(sub {
my( $body, $headers ) = @_;
...
})->get;
Posts the content to the URL and returns the body and headers, like the function in AnyEvent::HTTP. (yes, the description for this one is word-for-word the same as the POST one β the docs did that, not me, and I'm keeping it π) π
π SEE ALSO π
FutureAnyEvent::HTTPfor the details of the API
π REPOSITORY π
The public repository of this module is <https://github.com/Corion/future-http>.
go star it, it's giving community support π
π«Ά SUPPORT π«Ά
The public support forum of this module is <https://perlmonks.org/>. the monks are lovely, ask them anything, 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@rt.cpan.org.
(not me begging you to actually report the bugs instead of just suffering in silence π do it for us.)
β¨ AUTHOR β¨
Max Maischein "corion@cpan.org"
π COPYRIGHT (c) π
Copyright 2016-2024 by Max Maischein "corion@cpan.org".
π LICENSE π
This module is released under the same terms as Perl itself. iconic behavior, truly. π
and that's the whole page bestie, mwah π β this lil manual page came to you from perl v5.40.1, dated 2026-01-14, filed under Future::HTTP(3pm) in the User Contributed Perl Documentation. go write something async, ily π¦β¨
π¦ where this page comes from
- ubuntu resolute: libfuture-http-perl 0.17-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libfuture-http-perl 0.17-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms