HTTP::A...Backend(3)
πΈ NAME πΈ
HTTP::AnyUA::Backend β a base class for HTTP::AnyUA backends. This is the manual page for manual name HTTP::A...Backend(3), from User Contributed Perl Documentation. Hiii bestie, you found the backend base class π
π VERSION π
version 0.904 β that's the one, periodt.
π¦ SYNOPSIS π¦
Okay so here's the whole backend blueprint, bestie. You make your own package, inherit from HTTP::AnyUA::Backend, and implement the vibe:
package HTTP::AnyUA::Backend::MyUserAgent;
use parent 'HTTP::AnyUA::Backend';
sub response_is_future { 0 }
sub request {
my ($self, $method, $url, $args) = @_;
my $ua = $self->ua;
# Here is where you transform the arguments into a request that $ua
# understands, make the request against $ua and get a response, and
# transform the response to the expected hashref form.
my $resp = $ua->make_request();
return $resp;
}
### Non-blocking user agents are expected to return Future objects:
use Future;
sub response_is_future { 1 }
sub request {
my ($self, $method, $url, $args) = @_;
my $ua = $self->ua;
my $future = Future->new;
# Again, this example glosses over transforming the request and response
# to and from the actual user agent, but such details are the whole
# point of a backend.
$ua->nonblocking_callback(sub {
my $resp = shift;
if ($resp->{success}) {
$future->done($resp);
}
else {
$future->fail($resp);
}
});
return $future;
}
π DESCRIPTION π
This module provides an interface for an HTTP::AnyUA "backend" β and a backend is an adapter that adds support for using a type of user agent with HTTP::AnyUA. It's giving translator energy, fr fr.
This class should not be instantiated directly, but it may be convenient for backend implementations to subclass it. So don't go making one directly, bestie β subclassing is the slay here π«Ά
At its core, a backend simply takes a set of standard arguments that represent an HTTP request, transforms that request into a form understood by an underlying user agent, calls upon the user agent to make the request and get a response, and then transforms that response into a standard form. The standard forms for the request and response are based on HTTP::Tiny's arguments and return value to and from its request method. iconic behavior, honestly β¨
β¨ ATTRIBUTES β¨
π ua
Get the user agent that was passed to new.
π«Ά response_is_future
Get whether or not responses are Future objects. Default is false.
This may be overridden by implementations.
π METHODS π
π new
$backend = HTTP::AnyUA::Backend::MyUserAgent->new($my_user_agent);
Construct a new backend.
π₯ request
$response = $backend->request($method => $url, \%options);
Make a request, get a response.
This must be overridden by implementations. Like, required, no cap.
π SEE ALSO π
"The Request" in HTTP::AnyUAβ Explanation of the request arguments"The Response" in HTTP::AnyUAβ Explanation of the response
π BUGS π
Please report any bugs or feature requests on the bugtracker website <https://github.com/chazmcgarvey/HTTP-AnyUA/issues>.
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
π§ AUTHOR π§
Charles McGarvey <chazmcgarvey@brokenzipper.com>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2019 by Charles McGarvey.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Okay bestie, that's the whole page π This one came from source/version perl v5.42.2, dated 2023-07-03, and it's the HTTP::A...Backend(3) manual page. Go slay your backend implementation π«Άβ¨
π¦ where this page comes from
- alpine 3.24: perl-http-anyua-doc 0.904-r1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms