UniEvent::HTTP::Client - HTTP client connection
my $client = UE::HTTP::Client->new(); $client->request({ uri => "http://example.com", timeout => 3, response_callback => sub { my ($request, $response, $error) = @_; ... }, }); UE::Loop->default->run;
UniEvent::HTTP::Client represents single http client connection and it is the lowest-level API in UniEvent::HTTP. For high-level API see UniEvent::HTTP::UserAgent.
UniEvent::HTTP::Client
UniEvent::HTTP
Client can make many http requests but only one at a time (client doesn't support http pipelining for now). When client makes an http request and request is keep-alive, it doesn't close the connection when request is done. It will keep the connection alive, and if next http request targets the same destination with the same ssl and proxy settings, it will reuse that connection. If next http request targets another destination, connections will be closed and new connection will be established.
Client object will not die until active request is finished, even if it goes out of the scope.
Client inherits UniEvent::Tcp handle.
All methods of UniEvent::Tcp also apply. Keep in mind that if you intervene in network I/O via UniEvent::Tcp methods (like manually calling connect(), disconnect(), etc...) you may break Client's behaviour.
UniEvent::Tcp
connect()
disconnect()
Creates new client object which will use $loop UniEvent::Loop.
$loop
Executes an http request. Argument can be a UniEvent::HTTP::Request object or params to its constructor.
Cancels current http request execution (if any). Callbacks will be called with $error error (UniEvent::SystemError::operation_canceled by default). If no request is currently executing, does nothing.
$error
UniEvent::SystemError::operation_canceled
A property that controls automatic uncompression of response body. Default is true. If false body remains compressed, usefull for proxy.
To install UniEvent::HTTP, copy and paste the appropriate command in to your terminal.
cpanm
cpanm UniEvent::HTTP
CPAN shell
perl -MCPAN -e shell install UniEvent::HTTP
For more information on module installation, please visit the detailed CPAN module installation guide.