- DIFFERENCES FROM Net::Curl::Easy
- SEE ALSO
- WRAPPED METHODS
- STATIC FUNCTIONS
- LICENSE & COPYRIGHT
Net::Curl::Easier - Convenience wrapper around Net::Curl::Easy
my $easy = Net::Curl::Easier->new( url => 'http://perl.org' )->perform(); print $easy->body(); # … or, to dig in to the response: my $response = HTTP::Response->parse( $easy->head() . $easy->body() );
This module extends Net::Curl::Easy, with differences as noted here:
The response headers and body go to an internal buffer by default. Net::Curl::Easy simply adopts libcurl’s defaults, which is understandable but frequently unhelpful.
Character encoding. As of this writing Net::Curl::Easy uses SvPV to translate Perl strings to C, which means that what libcurl receives depends on how Perl internally stores your string. Thus, the same string given to Net::Curl::Easy can yield different input to libcurl depending on how Perl has decided to store that string.
This library fixes that by requiring all strings that it receives to be byte strings and normalizing Perl’s internal storage before calling into Net::Curl::Easy.
Several methods are wrapped, as described below.
Net::Curl::Simple takes a similar approach to this module but presents a substantially different interface.
Besides those inherited from Net::Curl::Easy, this class defines:
setopt()s multiple values in a single call. Instead of:
$easy->setopt( Net::Curl::Easy::CURLOPT_URL, 'http://perl.org' ); $easy->setopt( Net::Curl::Easy::CURLOPT_VERBOSE, 1 );
… you can do:
$easy->set( url => 'http://perl.org', verbose => 1 );
See curl_easy_setopt(3) for the full set of options you can give here.
Note that, since OBJ is returned, you can chain calls to this with calls to other methods like
You may not need to call this method since
new() calls it for you.
set(), but for
set(), but for
getinfo(). This, of course, doesn’t return OBJ, so it can’t be chained.
Returns OBJ’s internal HTTP response header buffer, as a byte string.
Returns the HTTP response body, as a byte string.
new()takes a list of key/value pairs and passes it to an internal call to
set(). The returned object will always be a (newly-created) hash reference.
send()apply the character encoding fix described above.
pushopt()fix character encoding and return the instance object.
perform()returns the instance object.
Net::Curl::Easy::strerror() is aliased in this module.
Copyright 2021 by Gasper Software Consulting. All rights reserved.
This library is licensed under the same terms as Perl itself. See perlartistic for details.