X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fp5-HTTP-AnyUA;a=blobdiff_plain;f=lib%2FHTTP%2FAnyUA%2FBackend%2FAnyEvent%2FHTTP.pm;fp=lib%2FHTTP%2FAnyUA%2FBackend%2FAnyEvent%2FHTTP.pm;h=334a664310c89de98659adfc9cc090bad8193035;hp=14f3b288e3e96cd11dca95e8a915ac78d14f510d;hb=8306d573a50cbac0d76bf01ce98e82beec36e42d;hpb=950a5203bb27c21b549742ce3dec05df1e331b59 diff --git a/lib/HTTP/AnyUA/Backend/AnyEvent/HTTP.pm b/lib/HTTP/AnyUA/Backend/AnyEvent/HTTP.pm index 14f3b28..334a664 100644 --- a/lib/HTTP/AnyUA/Backend/AnyEvent/HTTP.pm +++ b/lib/HTTP/AnyUA/Backend/AnyEvent/HTTP.pm @@ -6,6 +6,9 @@ package HTTP::AnyUA::Backend::AnyEvent::HTTP; This module adds support for the HTTP client L to be used with the unified programming interface provided by L. +If installed, requests will return L rather than L. This allows the use of +the C<< ->get >> method to await a result. + =head1 SEE ALSO =for :list @@ -24,6 +27,14 @@ use Future; use HTTP::AnyUA::Util; +my $future_class; +BEGIN { + $future_class = 'Future'; + eval 'use AnyEvent::Future'; ## no critic + $future_class = 'AnyEvent::Future' if !$@; +} + + =method options $backend->options(\%options); @@ -41,7 +52,7 @@ sub request { my ($method, $url, $args) = @_; my %opts = $self->_munge_request($method, $url, $args); - my $future = Future->new; + my $future = $future_class->new; require AnyEvent::HTTP; AnyEvent::HTTP::http_request($method => $url, %opts, sub {