NAME
LWP::Protocol::Net::Curl - the power of libcurl in the palm of your hands!
VERSION
version 0.004
SYNOPSIS
#!/usr/bin/env perl;
use common::sense;
use LWP::Protocol::Net::Curl;
use WWW::Mechanize;
...
DESCRIPTION
Drop-in replacement for LWP, WWW::Mechanize and their derivatives to use Net::Curl as a backend.
Advantages:
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 instancesasynchronous threading via Coro::Select (see eg/async.pl)
at last but not least: 100% compatible with both LWP and WWW::Mechanize test suites!
LIBCURL INTERFACE
You may query which LWP protocols are implemented through Net::Curl by accessing @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
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.
DEBUGGING
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!
TODO
better implementation for non-HTTP protocols
more tests
expose the inner guts of libcurl while handling encoding/redirects internally
revise Net::Curl::Multi "event loop" code
BUGS
complains about Attempt to free unreferenced scalar: SV 0xdeadbeef during global destruction.
SEE ALSO
LWP::Protocol::GHTTP - used as a reference
LWP::Protocol::AnyEvent::http - another reference
Net::Curl - backend for this module
LWP::Curl - provides LWP::UserAgent-compatible API for libcurl
AUTHOR
Stanislaw Pusep <stas@sysd.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2012 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.