Daisuke Murase > POE-Component-Client-HTTPDeferred > POE::Component::Client::HTTPDeferred

Download:
POE-Component-Client-HTTPDeferred-0.02.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.02   Source  

NAME ^

POE::Component::Client::HTTPDeferred - Yet another poco http client with twist like deferred interface.

SYNOPSIS ^

    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;

DESCRIPTION ^

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.

SEE ALSO ^

POE::Component::Client::HTTPDeferred::Deferred

METHODS ^

new

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.

request

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

Shutdown POE::Component::Client::HTTPDeferred session.

POE METHODS ^

Internal POE methods.

poe__start

poe_request

poe_response

AUTHOR ^

Daisuke Murase <typester@cpan.org>

COPYRIGHT AND LICENSE ^

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.

syntax highlighting: