AnyEvent::HTTP::LWP::UserAgent::Determined - a virtual browser that retries errors with AnyEvent
use strict; use AnyEvent::HTTP::LWP::UserAgent::Determined; my $browser = LWP::UserAgent::Determined->new; my $response = $browser->get($url, headers... ); $browser->get_async($url, headers... )->cb(sub { my $response = shift->recv; });
LWP::UserAgent::Determined works just like LWP::UserAgent (and is based on it, by being a subclass of it), except that when you use it to get a web page but run into a possibly-temporary error (like a DNS lookup timeout), it'll wait a few seconds and retry a few times.
It also adds some methods for controlling exactly what errors are considered retry-worthy and how many times to wait and for how many seconds, but normally you needn't bother about these, as the default settings are relatively sane.
This class not only works like LWP::UserAgent::Determined but also AnyEvent::HTTP::LWP::UserAgent (and is based on them, by being a subclass of them),
This module inherits all of LWP::UserAgent::Determined's methods and AnyEvent::HTTP::LWP::UserAgent's methods.
This class works by overriding AnyEvent::HTTP::LWP::UserAgent's simple_request method with its own around-method that just loops. See the source of this module; it's straightforward with caution of asynchronous nature.
simple_request
LWP, LWP::UserAgent, LWP::UserAgent::Determined, AnyEvent::HTTP, AnyEvent::HTTP::LWP::UserAgent
Original copyright for LWP::UserAgent::Determined:
Copyright 2004, Sean M. Burke, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.
Yasutaka ATARASHI yakex@cpan.org
yakex@cpan.org
Original authors of LWP::UserAgent::Determined are as follows:
Originally created by Sean M. Burke, sburke@cpan.org
sburke@cpan.org
Currently maintained by Jesse Vincent jesse@fsck.com
jesse@fsck.com
To install AnyEvent::HTTP::LWP::UserAgent::Determined, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AnyEvent::HTTP::LWP::UserAgent::Determined
CPAN shell
perl -MCPAN -e shell install AnyEvent::HTTP::LWP::UserAgent::Determined
For more information on module installation, please visit the detailed CPAN module installation guide.