WWW::Chain - A web request chain
version 0.003
# Coderef usage my $chain = WWW::Chain->new(HTTP::Request->new( GET => 'http://localhost/' ), sub { my ( $chain, $response ) = @_; $chain->stash->{first_request} = 'done'; return HTTP::Request->new( GET => 'http://localhost/' ), HTTP::Request->new( GET => 'http://other.localhost/' ), sub { my ( $chain, $first_response, $second_response ) = @_; $chain->stash->{two_calls_finished} = 'done'; return; }; }); # Method usage (can be mixed with Coderef) { package TestWWWChainMethods; use Moo; extends 'WWW::Chain'; sub first_request { $_[0]->stash->{a} = 1; return HTTP::Request->new( GET => 'http://duckduckgo.com/' ), "second_request"; } sub second_request { $_[0]->stash->{b} = 2; return; } } my $chain = TestWWWChainMethods->new(HTTP::Request->new( GET => 'http://duckduckgo.com/' ), 'first_request'); # Blocking usage: my $ua = WWW::Chain::UA::LWP->new; $ua->request_chain($chain); # ... or non blocking usage example: my @http_requests = @{$chain->next_requests}; # ... do something with the HTTP::Request objects to get HTTP::Response objects $chain->next_responses(@http_responses); # repeat those till $chain->done # Working with the result print $chain->stash->{two_calls_finished};
The implementation is not finished (but fully working), API changes may occur...
Torsten Raudssus <torsten@raudss.us>
This software is copyright (c) 2012 by Torsten Raudssus.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install WWW::Chain, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::Chain
CPAN shell
perl -MCPAN -e shell install WWW::Chain
For more information on module installation, please visit the detailed CPAN module installation guide.