POE::Declare::HTTP::Client - A simple HTTP client based on POE::Declare
# Create the web server my $http = POE::Declare::HTTP::Client->new( Timeout => 10, MaxRedirect => 7, ResponseEvent => \&on_response, ShutdownEvent => \&on_shutdown, ); # Control with methods $http->start; $http->GET('http://google.com'); $http->stop;
This module provides a simple HTTP client based on POE::Declare.
The implemenetation is intentionally minimalist, making this module an ideal choice for creating specialised web clients embedded in larger applications.
my $server = POE::Declare::HTTP::Client->new( ResponseEvent => \&on_response, ShutdownEvent => \&on_shutdown, );
The new constructor sets up a reusable HTTP client that can be enabled and disabled repeatedly as needed.
new
The start method enables the web server. If the server is already running, this method will shortcut and do nothing.
start
If called before POE has been started, the web server will start immediately once POE is running.
The stop method disables the web server. If the server is not running, this method will shortcut and do nothing.
stop
$client->GET('http://www.cpan.org/');
The GET method fetches a named URL via a HTTP GET request.
GET
$client->HEAD('http://www.cpan.org/');
The HEAD method fetches headers for a named URL via a HTTP HEAD request.
HEAD
$client->POST('http://www.cpan.org/');
The POST method fetches a named URL via a HTTP POST request.
POST
$client->PUT( 'http://127.0.0.1:12345/upload.txt', Content => 'This is the file content', );
The PUT method uploads content to a named URL via a HTTP PUT request.
PUT
$client->DELETE('http://www.cpan.org/');
The DELETE method deletes a resource at a URL via a HTTP DELETE request.
DELETE
$client->request( $HTTP_Request );
The request method triggers an arbitrary HTTP request.
request
It takes any HTTP::Request object, and will respond with an HTTP::Response object to the ResponseEvent message handler once it is completed.
ResponseEvent
The boolean running method returns true if the client is both spawned and processing a request, or false if not. Note that it does not distinguish between running and idle, and stopped entirely.
running
Bugs should be always be reported via the CPAN bug tracker at
http://rt.cpan.org/NoAuth/ReportBug.html?Queue=POE-Declare-HTTP-Client
For other issues, or commercial enhancement or support, contact the author.
Adam Kennedy <adamk@cpan.org>
POE, http://ali.as/
Copyright 2011 Adam Kennedy.
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::Declare::HTTP::Client, copy and paste the appropriate command in to your terminal.
cpanm
cpanm POE::Declare::HTTP::Client
CPAN shell
perl -MCPAN -e shell install POE::Declare::HTTP::Client
For more information on module installation, please visit the detailed CPAN module installation guide.