Станислав Пусеп > LWP-Protocol-Net-Curl-0.021 > LWP::Protocol::Net::Curl

Download:
LWP-Protocol-Net-Curl-0.021.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: 0.021   Source   Latest Release: LWP-Protocol-Net-Curl-0.022

NAME ^

LWP::Protocol::Net::Curl - the power of libcurl in the palm of your hands!

VERSION ^

version 0.021

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:

LIBCURL INTERFACE ^

You may query which LWP protocols are implemented through Net::Curl by accessing @LWP::Protocol::Net::Curl::implements or %LWP::Protocol::Net::Curl::implements.

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 X-CurlOpt-):

    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.

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 ^

BUGS ^

SEE ALSO ^

AUTHOR ^

Stanislaw Pusep <stas@sysd.org>

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.

syntax highlighting: