POE::Component::Client::HTTPDeferred - Yet another poco http client with twist like deferred interface.
use POE qw/Component::Client::HTTPDeferred/; use HTTP::Request::Common; POE::Session->create( inline_states => { _start => sub { my $ua = POE::Component::Client::HTTPDeferred->new; my $d = $ua->request( GET 'http://example.com/' ); $d->addBoth(sub { my $res = shift; if ($res->is_success) { print $res->as_string; } else { warn $res->status_line; } $ua->shutdown; }); }, }, ); POE::Kernel->run;
POE::Component::Client::HTTPDeferred is a wrapper module to add twist (or MochiKit) like callback interface to POE::Component::Client::HTTP.
To use this module, you can use code reference as response callback. So you don't have to create POE state for handling response.
POE::Component::Client::HTTPDeferred::Deferred
Create POE::Component::Client::HTTPDeferred instance.
my $ua = POE::Component::Client::HTTPDeferred->new;
Once you call this, POE::Component::Client::HTTPDeferred will start POE::Session for own use. So you need to call ->shutdown method to stop the session.
Send HTTP request and return Deferred object (POE::Component::Client::HTTPDeferred::Deferred).
my $d = $ua->request($request);
This $request argument should be HTTP::Request object.
Shutdown POE::Component::Client::HTTPDeferred session.
Internal POE methods.
Daisuke Murase <typester@cpan.org>
Copyright (c) 2008-2009 by KAYAC Inc.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module.
To install POE::Component::Client::HTTPDeferred, copy and paste the appropriate command in to your terminal.
cpanm
cpanm POE::Component::Client::HTTPDeferred
CPAN shell
perl -MCPAN -e shell install POE::Component::Client::HTTPDeferred
For more information on module installation, please visit the detailed CPAN module installation guide.