NAME

Web::Magic::Async - asynchronous HTTP dwimmery

SYNOPSIS

 use Web::Magic::Async -sub => 'W'; 
 say W('http://json-schema.org/card')->{description};

DESCRIPTION

An asynchronous drop-in replacement for Web::Magic. Differences are noted below.

do_request

Starts the HTTP request in the background, and returns immediately. While in Web::Magic, you'd rarely call this method explicitly, in Web::Magic::Async, call it as soon as you can (once you've finished specifying request headers, etc) so that your code can get on with other stuff while the HTTP stuff happens in the background.

response

Blocks until the HTTP request has completed.

headers

Blocks until at least the HTTP headers have been received.

is_requested

If a request is in progress, blocks until it has finished before returning true.

is_in_progress

Returns true if and only if the HTTP request is currently in progress. This method does not exist in Web::Magic itself.

cancel

Usually, this will throw an error if called on a Web::Magic object that has already been requested. Asynchronous requests can be cancelled while they are still in progress, but not once they are complete.

user_agent

Web::Magic::Async does not use LWP::UserAgent, so this method throws a Web::Magic::Exception.

BUGS

Uncountable, almost certainly.

Have a go at counting them here: http://rt.cpan.org/Dist/Display.html?Queue=Web-Magic.

Web::Magic::Async probably has more bugs lurking within it than Web::Magic does. Unless you absolutely need the extra asynchronous magic it provides, it's probably better to stick with Web::Magic for now.

SEE ALSO

Web::Magic, AnyEvent, AnyEvent::HTTP.

AUTHOR

Toby Inkster <tobyink@cpan.org>.

COPYRIGHT AND LICENCE

This software is copyright (c) 2011-2012 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

DISCLAIMER OF WARRANTIES

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.