=begin pod

=head1 NAME

LibCurl::EasyHandle

=head1 SYNOPSIS

  use LibCurl::EasyHandle;

  curl_global_init(CURL_GLOBAL_DEFAULT);

  say curl_version;

  my $handle = LibCurl::EasyHandle.new;

  $handle.setopt(CURLOPT_URL, "http://example.com");

  $handle.perform;

  say $handle.getinfo(CURL_GETINFO_RESPONSE_CODE);

  $handle.cleanup;

  curl_global_cleanup;

=head1 DESCRIPTION

B<LibCurl::EasyHandle> is the low level NativeCall interface to
libcurl's L<easy
interface|https://curl.haxx.se/libcurl/c/libcurl-easy.html>.  In
general you should be using the B<LibCurl::Easy> interface instead.

=head2 SUBROUTINES

=item sub B<curl_global_init>(long $flags) returns uint32

Nativecall version of
L<B<curl_global_init>|https://curl.haxx.se/libcurl/c/curl_global_init.html>. It
can take the following I<$flags>: CURL_GLOBAL_SSL, CURL_GLOBAL_WIN32,
CURL_GLOBAL_ALL, CURL_GLOBAL_NOTHING, CURL_GLOBAL_DEFAULT,
CURL_GLOBAL_ACK_EINTR.

=item sub B<curl_global_cleanup>()

Nativecall version of
L<B<curl_global_cleanup>|https://curl.haxx.se/libcurl/c/curl_global_cleanup.html>.

=item sub B<curl_version>() returns Str

Nativecall version of
L<B<curl_version>|https://curl.haxx.se/libcurl/c/curl_version.html>.

=head2 CLASSES

=head3 class B<X::LibCurl> is Exception

Wraps libcurl error code.

=item method B<Int>() returns Int

Returns the CURLcode for the error.

=item method B<message>() returns Str

Returns the Str version of the error from
L<B<curl_easy_strerror>|https://curl.haxx.se/libcurl/c/curl_easy_strerror.html>.

=head3 class B<LibCurl::slist-struct> is repr('CStruct')

Wrapper for B<struct curl_slist>.

=item has Str $.data
=item has Pointer $.next

=head3 class B<LibCurl::slist> is repr('CPointer')

Wrapper for a pointer to a B<struct curl_slist>.

=item method B<append>(*@str-list) returns LibCurl::slist

Wrapper for
L<B<curl_slist_append>|https://curl.haxx.se/libcurl/c/curl_slist_append.html>,
but can take a list of strings and they all get appended.

=item method B<list>() returns Array

Extract the list of strings into a Perl Array.

=item method B<free>()

Wrapper for
L<B<curl_slist_free_all>|https://curl.haxx.se/libcurl/c/curl_slist_free_all.html>.

=head3 B<LibCurl::certinfo> is repr('CStruct')

=head3 B<LibCurl::EasyHandle> is repr('CStruct')

Wrapper for B<struct CURL>.

=item method B<new>() returns LibCurl::EasyHandle

Wrapper for
L<B<curl_easy_init>|https://curl.haxx.se/libcurl/c/curl_easy_init.html>
to create a new CURL easy handle.

=item method B<id>() returns Str

Returns an opaque string that will be unique for every
B<LibCurl::EasyHandle>.

=item method B<cleanup>()

Wrapper for
L<B<curl_easy_cleanup>|https://curl.haxx.se/libcurl/c/curl_easy_cleanup.html>.

=item method B<reset>()

Wrapper for
L<B<curl_easy_reset>|https://curl.haxx.se/libcurl/c/curl_easy_reset.html>.

=item method B<duphandle>() returns LibCurl::EasyHandle

Wrapper for
L<B<curl_easy_duphandle>|https://curl.haxx.se/libcurl/c/curl_easy_duphandle.html>.

=item method B<escape>(Str $str, $encoding = 'utf-8')

Wrapper for
L<B<curl_easy_escape>|https://curl.haxx.se/libcurl/c/curl_easy_escape.html>.

=item method B<unescape>(Str $str, $encoding = 'utf-8')

Wrapper for
L<B<curl_easy_unescape>|https://curl.haxx.se/libcurl/c/curl_easy_unescape.html>.

=item method B<perform>() return uint32

Wrapper for
L<B<curl_easy_perform>|https://curl.haxx.se/libcurl/c/curl_easy_perform.html>.

=item multi method B<setopt>($option, Str $param)
=item multi method B<setopt>($option, &callback)
=item multi method B<setopt>($option, Pointer $ptr)
=item multi method B<setopt>($option, LibCurl::slist $slist)
=item multi method B<setopt>($option, CArray[uint8] $ptr)
=item multi method B<setopt>($option, LibCurl::EasyHandle $ptr)

Wrappers for various flavors of 
L<B<curl_easy_setopt>|https://curl.haxx.se/libcurl/c/curl_easy_setopt.html>.

These will throw an X::LibCurl on any error.

=item method B<getinfo_long>($option) returns long
=item method B<getinfo_double>($option) returns num64
=item method B<getinfo_str>($option) returns Str
=item method B<getinfo_certinfo>() returns Array[Str]
=item method B<getinfo_slist>($option) returns Array[Str]

Wrappers for various flavors of 
L<B<curl_easy_getinfo>|https://curl.haxx.se/libcurl/c/curl_easy_getinfo.html>.

These will throw an X::LibCurl on any error.

=end pod
