POEFetch uses the smart/crazy POE framework to reel in URLs en masse.
POE is a nice alternative to pre-forking or multi-threading.
The POE framework relies on cooperative multi-tasking and runs its
tasks in a single-process and single-threaded mode and takes advantage
of the fact that there's free processor cycles while we're waiting for
slower operations (like waiting for a network response).
POEFetcher
works both with plain HTTP and SSL. Also, basic authentication is supported.
Constructor, creates the fetcher object, capable of registering and
then reeling in an arbitrary number of HTTP::Requests.
It accepts optional parameter settings, currently the number of
requests processed in parallel can be provided in max_kids:
my $fetcher = POEFetcher->new( max_kids => 10 );
will cause the POEFetcher to run 10 requests in parallel. The default is
5. The maximum throughput has to be determined empirically, reasonable
values for max_kids have been found to be between 5 and 10.
Fires up all registered requests in a quasi-parallel way (but never
more than max_kids (see new()) at a time.
The function will block until the last URL has been reeled in.
Every element of the result array
is of type HTTP::Response and can be queried for success/failure
with its standard is_success/is_error methods.
Please note that the PoCo::HTTP::Client used internally won't follow
302s automatically but return them as errors.
Results are stored in the same order as the original requests were registered
in. But just in case you lost track of the URLs requested in the first
place, every HTTP::Response
object provides the original URL in $resp->request()->url().
Copyright 2002 by Mike Schilli, all rights reserved.
This program is free software, you can redistribute it and/or
modify it under the same terms as Perl itself.