- LIBCURL INTERFACE
- SEE ALSO
- COPYRIGHT AND LICENSE
LWP::Protocol::Net::Curl - the power of libcurl in the palm of your hands!
#!/usr/bin/env perl; use common::sense; use LWP::Protocol::Net::Curl; use WWW::Mechanize; ...
support ftp/ftps/http/https/sftp/scp protocols out-of-box (secure layer require libcurl to be compiled with TLS/SSL/libssh2 support)
support SOCKS4/5 proxy out-of-box
connection persistence and DNS cache (independent from LWP::ConnCache)
lightning-fast HTTP compression and redirection
lower CPU usage: this matters if you
fork()multiple downloader instances
asynchronous threading via Coro::Select (see eg/async.pl)
By default, every protocol listed in that array will be implemented via LWP::Protocol::Net::Curl. It is possible to import only specific protocols:
use LWP::Protocol::Net::Curl takeover => 0; LWP::Protocol::implementor(https => 'LWP::Protocol::Net::Curl');
The default value of
takeover option is true, resulting in exactly the same behavior as in:
use LWP::Protocol::Net::Curl takeover => 0; LWP::Protocol::implementor($_ => 'LWP::Protocol::Net::Curl') for @LWP::Protocol::Net::Curl::implements;
Default curl_easy_setopt() options can be set during initialization:
use LWP::Protocol::Net::Curl encoding => '', # use HTTP compression by default referer => 'http://google.com/', verbose => 1; # make libcurl print lots of stuff to STDERR
Or during runtime, using special HTTP headers (prefixed by
use LWP::Protocol::Net::Curl; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $res = $ua->get( 'https://metacpan.org/', X_CurlOpt_Verbose => 1, );
Options set this way have the lowest precedence. For instance, if WWW::Mechanize sets the Referer: by it's own, the value you defined above won't be used.
Quickly enable libcurl verbose mode via
PERL5OPT environment variable:
PERL5OPT=-MLWP::Protocol::Net::Curl=verbose,1 perl your-script.pl
Bonus: it works even if you don't include the
use LWP::Protocol::Net::Curl line!
better implementation for non-HTTP protocols
expose the inner guts of libcurl while handling encoding/redirects internally
revise Net::Curl::Multi "event loop" code
sometimes still complains about Attempt to free unreferenced scalar: SV 0xdeadbeef during global destruction.
in "async mode", each LWP::UserAgent instance "blocks" until all requests finish
Net::Curl::Share support is disabled on threaded Perl builds
Net::Curl - backend for this module
Stanislaw Pusep <email@example.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Stanislaw Pusep.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.