HTTP::Curl - HTTP interface for Net::Curl (clone of HTTP::Any::Curl)
use HTTP::Curl; my ($is_success, $body, $headers, $redirects) = HTTP::Curl::do_http($easy, $url, $opt);
use Net::Curl::Easy; use HTTP::Curl; my $easy = Net::Curl::Easy->new(); my ($is_success, $body, $headers, $redirects) = HTTP::Curl::do_http($easy, $url, $opt); or my $cb = sub { my ($is_success, $body, $headers, $redirects) = @_; ... }; HTTP::Curl::do_http(undef, $easy, $url, $opt, $cb);
use Net::Curl::Easy; use Net::Curl::Multi; use Net::Curl::Multi::EV; use HTTP::Curl; my $multi = Net::Curl::Multi->new(); my $curl_ev = Net::Curl::Multi::EV::curl_ev($multi); my $easy = Net::Curl::Easy->new(); my $cb = sub { my ($is_success, $body, $headers, $redirects) = @_; ... }; HTTP::Curl::do_http($curl_ev, $easy, $url, $opt, $cb); ...
URL as string
options and headers
callback function to get result
Referer url
User agent name
Timeout, seconds
This option adds 'Accept-Encoding' header to the HTTP query and tells that the response must be decoded. If you don't want to decode the response, please add 'Accept-Encoding' header into the 'headers' parameter.
Ref on HASH of HTTP headers:
{ 'Accept' => '*/*', ... }
It enables cookies support. The "" values enables the session cookies support without saving them.
1 or 0. Try to create/reuse a persistent connection. When not specified, see the default behavior of Curl (reverse of CURLOPT_FORBID_REUSE).
http and socks proxy
proxy => "$host:$port" or proxy => "$scheme://$host:$port" where scheme can be one of the: http, socks (socks5), socks5, socks4.
The size limit for response content, bytes.
HTTP::Curl - will return the result partially.
When max_size options will be triggered, 'client-aborted' header will added with 'max_size' value.
The limit of how many times it will obey redirection responses in a given request cycle.
By default, the value is 7.
Data for POST method.
String or CODE ref to return strings (return undef is end of body data).
When method parameter is "POST", the POST request is used with body parameter on data and 'Content-Type' header is added with 'application/x-www-form-urlencoded' value.
my $cb = sub { my ($is_success, $body, $headers, $redirects) = @_; ... };
where:
It is true, when HTTP code is 2XX.
HTML body. When on_header callback function is defined, then body is undef.
Ref on HASH of HTTP headers (lowercase) and others info: Status, Reason, URL
Previous headers from last to first
When specified, this callback will be called after getting all headers.
$opt{on_header} = sub { my ($is_success, $headers, $redirects) = @_; ... };
When specified, this callback will be called on each chunk.
$opt{on_body} = sub { my ($body) = @_; # body chunk ... };
Turn off the persistent options to download pages of many sites.
Use libcurl with "Asynchronous DNS resolution via c-ares".
Nick Kostyria <kni@cpan.org>
Copyright (C) 2013 by Nick Kostyria
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available.
Net::Curl Net::Curl::Multi::EV Net::Any
To install HTTP::Curl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTTP::Curl
CPAN shell
perl -MCPAN -e shell install HTTP::Curl
For more information on module installation, please visit the detailed CPAN module installation guide.