IOMux::HTTP::Client - HTTP client implementation
IOMux::HTTP::Client is a IOMux::HTTP is a IOMux::Net::TCP is a IOMux::Handler::Read is a IOMux::Handler IOMux::Net::TCP also extends IOMux::Handler::Write is a IOMux::Handler::Write is a IOMux::Handler
my $socket = IO::Socket::INET->new(@sock_params); my $socket = IO::Socket::SSL->new(@sock_params); my $client = IOMux::HTTP::Client->new(socket => $socket); $mux->add($client); # or in one go: my $client = $mux->add(IOMux::HTTP::Client->new(@sock_params));
Handles a HTTP/1.1 connection to a HTTP server, for IOMux based applications only. The multiplexer allows one application to sent requests and receive answers from multiple servers in parallel in one single process.
WARNING: Writing event driven programs in a challenge.
Send the request to the server. When the whole message has been sent, the CALLBACK will be called. You may send more REQUESTS in a row, which will be handled in-order by the server.
See a detailed example farther below in this man-page.
Often, HTTP interactions are rather stateless: simply requesting some files to be downloaded. However, more and more applications use HTTP as generic transport protocol with more complex message interchange. This module cleanly supports state transitions. See them as tasks to perform.
Any client implementation starts off like this
my $server = "localhost:8081"; # You may also choose IOMux::Select or other # multiplex instances (to be developed) use IOMux::Poll; my $mux = IOMux::Poll->new; use IOMux::HTTP::Client; my $client = IOMux::HTTP::Client->new(PeerAddr => $server); $mux->add($client); # A session HASH (you may create a nice object around it) # will be passed from step to step. my $session = {}; # Take the first step step1($client, $session); # You may initiate multiple clients and start many different steps # until you start the loop. $mux->loop; # The loop is left when all connections have closed exit 0; # Now here comes the implementation as shown in the examples below.
This module is part of IOMux-HTTP distribution version 0.11, built on January 27, 2011. Website: http://perl.overmeer.net/ All modules in this suite: "Any::Daemon", "IOMux", and "IOMux::HTTP".
Please post questions or ideas to perl@overmeer.net
Copyrights 2011 by Mark Overmeer. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html
To install IOMux::HTTP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IOMux::HTTP
CPAN shell
perl -MCPAN -e shell install IOMux::HTTP
For more information on module installation, please visit the detailed CPAN module installation guide.