view release on metacpan or search on metacpan
Curl_Easy.xsh view on Meta::CPAN
/* this may trigger a callback,
* we want it while easy handle is still alive */
curl_easy_setopt( easy->handle, CURLOPT_SHARE, NULL );
/* when using multi handle, the connection may stay open in that multi,
* but the easy will be long dead. In case of ftp for instance, connection
* closing will send a trailer with no apparent destination */
/* this also disables header callback if not using multi, SORRY */
curl_easy_setopt( easy->handle, CURLOPT_HEADERFUNCTION, NULL );
curl_easy_setopt( easy->handle, CURLOPT_WRITEHEADER, NULL );
/* If Perl reaps an easy and its multi "together", there is a
* chance Perl might clear the easy first, leading to a segfault when
* the multi tries to remove an easy that is already cleaned up.
* This prevents that. */
perl_curl_easy_remove_from_multi( aTHX_ easy );
if ( easy->handle )
curl_easy_cleanup( easy->handle );
Curl_Easy.xsh view on Meta::CPAN
croak( "object base must be a valid reference\n" );
sclass = sv_reftype( SvRV( ST(0) ), TRUE );
clone = perl_curl_easy_duphandle( easy );
perl_curl_easy_preset( clone );
if ( easy->cb[ CB_EASY_HEADER ].func
|| easy->cb[ CB_EASY_HEADER ].data ) {
curl_easy_setopt( clone->handle, CURLOPT_HEADERFUNCTION, cb_easy_header );
curl_easy_setopt( clone->handle, CURLOPT_WRITEHEADER, clone );
}
if ( easy->cb[ CB_EASY_PROGRESS ].func ) {
curl_easy_setopt( clone->handle, CURLOPT_PROGRESSFUNCTION, cb_easy_progress );
curl_easy_setopt( clone->handle, CURLOPT_PROGRESSDATA, clone );
}
//
#ifdef CURLOPT_XFERINFOFUNCTION
# ifdef CURLOPT_XFERINFODATA
if ( easy->cb[ CB_EASY_XFERINFO ].func ) {
Curl_Easy_setopt.c view on Meta::CPAN
case CURLOPT_WRITEFUNCTION:
/* function registered already */
cbnum = CB_EASY_WRITE;
break;
case CURLOPT_READFUNCTION:
/* function registered already */
cbnum = CB_EASY_READ;
break;
case CURLOPT_HEADERFUNCTION:
funcptr = cb_easy_header;
dataopt = CURLOPT_WRITEHEADER;
cbnum = CB_EASY_HEADER;
break;
case CURLOPT_PROGRESSFUNCTION:
funcptr = cb_easy_progress;
dataopt = CURLOPT_PROGRESSDATA;
cbnum = CB_EASY_PROGRESS;
break;
#ifdef CURLOPT_XFERINFODATA
# ifdef CURLOPT_XFERINFOFUNCTION
case CURLOPT_XFERINFOFUNCTION:
Curl_Easy_setopt.c view on Meta::CPAN
int cbnum = CB_EASY_LAST;
CURLcode ret = CURLE_OK;
switch ( option ) {
case CURLOPT_FILE:
cbnum = CB_EASY_WRITE;
break;
case CURLOPT_INFILE:
cbnum = CB_EASY_READ;
break;
case CURLOPT_WRITEHEADER:
/* cb_easy_header has default writer function,
* but no default destination */
{
CURLcode ret2;
ret = curl_easy_setopt( easy->handle, CURLOPT_HEADERFUNCTION,
SvOK( value ) ? cb_easy_header : NULL );
ret2 = curl_easy_setopt( easy->handle, option,
SvOK( value ) ? easy : NULL );
if ( ret == CURLE_OK )
ret = ret2;
examples/02-multi-simple.pl view on Meta::CPAN
sub easy
{
my $uri = shift;
my $share = shift;
require Net::Curl::Easy;
my $easy = Net::Curl::Easy->new( { uri => $uri, body => '' } );
$easy->setopt( Net::Curl::Easy::CURLOPT_VERBOSE(), 1 );
$easy->setopt( Net::Curl::Easy::CURLOPT_URL(), $uri );
$easy->setopt( Net::Curl::Easy::CURLOPT_WRITEHEADER(),
\$easy->{headers} );
$easy->setopt( Net::Curl::Easy::CURLOPT_FILE(),
\$easy->{body} );
$easy->setopt( Net::Curl::Easy::CURLOPT_SHARE(), $share );
# This wasn't needed prior to curl 7.67, which changed the interface
# so that an easy that uses a cookie-share now requires an explicit
# cookie-engine enable to use cookies. Previously the easy's use of
# a cookie-share implicitly enabled the easy's cookie engine.
$easy->setopt( Net::Curl::Easy::CURLOPT_COOKIEFILE(), q<> );
examples/03-multi-event.pl view on Meta::CPAN
sub new
{
my $class = shift;
my $uri = shift;
my $cb = shift;
my $easy = $class->SUPER::new(
{ uri => $uri, body => '', cb => $cb }
);
$easy->setopt( CURLOPT_URL, $uri );
$easy->setopt( CURLOPT_WRITEHEADER, \$easy->{headers} );
$easy->setopt( CURLOPT_FILE, \$easy->{body} );
return $easy;
}
sub finish
{
my ( $easy, $result ) = @_;
printf "\nFinished downloading %s: %s: %d bytes\n",
examples/04-share-threads.pl view on Meta::CPAN
use Net::Curl::Easy qw(/^CURLOPT_.*/);
use base qw(Net::Curl::Easy);
sub new
{
my $class = shift;
my $share = shift;
my $easy = $class->SUPER::new( { body => '', head => '' } );
$easy->setopt( CURLOPT_VERBOSE, 1 );
$easy->setopt( CURLOPT_WRITEHEADER, \$easy->{head} );
$easy->setopt( CURLOPT_FILE, \$easy->{body} );
$easy->setopt( CURLOPT_HEADERFUNCTION, \&cb_header );
$easy->setopt( CURLOPT_SHARE, $share );
return $easy;
}
sub cb_header {
my ( $easy, $data, $uservar ) = @_;
examples/05-irssi-downloader.pl view on Meta::CPAN
sub new
{
my $class = shift;
my $uri = shift;
my $cb = shift;
my $easy = $class->SUPER::new(
{ body => '', headers => '' }
);
# some sane defaults
$easy->setopt( CURLOPT_WRITEHEADER, \$easy->{headers} );
$easy->setopt( CURLOPT_FILE, \$easy->{body} );
$easy->setopt( CURLOPT_TIMEOUT, 300 );
$easy->setopt( CURLOPT_CONNECTTIMEOUT, 60 );
$easy->setopt( CURLOPT_MAXREDIRS, 20 );
$easy->setopt( CURLOPT_FOLLOWLOCATION, 1 );
$easy->setopt( CURLOPT_ENCODING, 'gzip,deflate' ) if $has_zlib;
$easy->setopt( CURLOPT_SSL_VERIFYPEER, 0 );
$easy->setopt( CURLOPT_COOKIEFILE, '' );
$easy->setopt( CURLOPT_USERAGENT, 'Irssi + Net::Curl' );
inc/symbols-in-versions view on Meta::CPAN
CURLOPT_UPLOAD_BUFFERSIZE 7.62.0
CURLOPT_URL 7.1
CURLOPT_USE_SSL 7.17.0
CURLOPT_USERAGENT 7.1
CURLOPT_USERNAME 7.19.1
CURLOPT_USERPWD 7.1
CURLOPT_VERBOSE 7.1
CURLOPT_WILDCARDMATCH 7.21.0
CURLOPT_WRITEDATA 7.9.7
CURLOPT_WRITEFUNCTION 7.1
CURLOPT_WRITEHEADER 7.1
CURLOPT_WRITEINFO 7.1
CURLOPT_WS_OPTIONS 7.86.0
CURLOPT_XFERINFODATA 7.32.0
CURLOPT_XFERINFOFUNCTION 7.32.0
CURLOPT_XOAUTH2_BEARER 7.33.0
CURLOPTDEPRECATED 7.87.0
CURLOPTTYPE_BLOB 7.71.0
CURLOPTTYPE_CBPOINT 7.73.0
CURLOPTTYPE_FUNCTIONPOINT 7.1
CURLOPTTYPE_LONG 7.1
lib/Net/Curl/Easy.pm view on Meta::CPAN
=item CURLOPT_XFERINFOFUNCTION ( CURLOPT_XFERINFODATA ) 7.32.0+
Works exactly like CURLOPT_PROGRESSFUNCTION callback, except that dltotal, dlnow, ultotal
and ulnow are now integer values instead of double.
Since CURLOPT_XFERINFODATA is an alias to CURLOPT_PROGRESSDATA,
they both set the same callback data for both
CURLOPT_PROGRESSFUNCTION and CURLOPT_PROGRESSFUNCTION callbacks.
=item CURLOPT_HEADERFUNCTION ( CURLOPT_WRITEHEADER )
Behaviour is the same as in write callback. Callback is called once for
every header line.
=item CURLOPT_DEBUGFUNCTION ( CURLOPT_DEBUGDATA )
Debug callback receives 4 arguments: easy object, message type, debug data
and CURLOPT_DEBUGDATA value. Must return 0.
sub cb_debug {
lib/Net/Curl/examples.pod view on Meta::CPAN
sub easy
{
my $uri = shift;
my $share = shift;
require Net::Curl::Easy;
my $easy = Net::Curl::Easy->new( { uri => $uri, body => '' } );
$easy->setopt( Net::Curl::Easy::CURLOPT_VERBOSE(), 1 );
$easy->setopt( Net::Curl::Easy::CURLOPT_URL(), $uri );
$easy->setopt( Net::Curl::Easy::CURLOPT_WRITEHEADER(),
\$easy->{headers} );
$easy->setopt( Net::Curl::Easy::CURLOPT_FILE(),
\$easy->{body} );
$easy->setopt( Net::Curl::Easy::CURLOPT_SHARE(), $share );
# This wasn't needed prior to curl 7.67, which changed the interface
# so that an easy that uses a cookie-share now requires an explicit
# cookie-engine enable to use cookies. Previously the easy's use of
# a cookie-share implicitly enabled the easy's cookie engine.
$easy->setopt( Net::Curl::Easy::CURLOPT_COOKIEFILE(), q<> );
lib/Net/Curl/examples.pod view on Meta::CPAN
sub new
{
my $class = shift;
my $uri = shift;
my $cb = shift;
my $easy = $class->SUPER::new(
{ uri => $uri, body => '', cb => $cb }
);
$easy->setopt( CURLOPT_URL, $uri );
$easy->setopt( CURLOPT_WRITEHEADER, \$easy->{headers} );
$easy->setopt( CURLOPT_FILE, \$easy->{body} );
return $easy;
}
sub finish
{
my ( $easy, $result ) = @_;
printf "\nFinished downloading %s: %s: %d bytes\n",
lib/Net/Curl/examples.pod view on Meta::CPAN
use Net::Curl::Easy qw(/^CURLOPT_.*/);
use base qw(Net::Curl::Easy);
sub new
{
my $class = shift;
my $share = shift;
my $easy = $class->SUPER::new( { body => '', head => '' } );
$easy->setopt( CURLOPT_VERBOSE, 1 );
$easy->setopt( CURLOPT_WRITEHEADER, \$easy->{head} );
$easy->setopt( CURLOPT_FILE, \$easy->{body} );
$easy->setopt( CURLOPT_HEADERFUNCTION, \&cb_header );
$easy->setopt( CURLOPT_SHARE, $share );
return $easy;
}
sub cb_header {
my ( $easy, $data, $uservar ) = @_;
lib/Net/Curl/examples.pod view on Meta::CPAN
sub new
{
my $class = shift;
my $uri = shift;
my $cb = shift;
my $easy = $class->SUPER::new(
{ body => '', headers => '' }
);
# some sane defaults
$easy->setopt( CURLOPT_WRITEHEADER, \$easy->{headers} );
$easy->setopt( CURLOPT_FILE, \$easy->{body} );
$easy->setopt( CURLOPT_TIMEOUT, 300 );
$easy->setopt( CURLOPT_CONNECTTIMEOUT, 60 );
$easy->setopt( CURLOPT_MAXREDIRS, 20 );
$easy->setopt( CURLOPT_FOLLOWLOCATION, 1 );
$easy->setopt( CURLOPT_ENCODING, 'gzip,deflate' ) if $has_zlib;
$easy->setopt( CURLOPT_SSL_VERIFYPEER, 0 );
$easy->setopt( CURLOPT_COOKIEFILE, '' );
$easy->setopt( CURLOPT_USERAGENT, 'Irssi + Net::Curl' );
t/60-multi-wait.t view on Meta::CPAN
for my $i (1 .. $n) {
my $easy = Net::Curl::Easy->new() or die "cannot curl";
$multi->add_handle($easy);
$easy->setopt(CURLOPT_NOPROGRESS, 1);
$easy->setopt(CURLOPT_FOLLOWLOCATION, 1);
$easy->setopt(CURLOPT_TIMEOUT, 30);
open(my $head, "+>", undef);
Net::Curl::Easy::setopt($easy, CURLOPT_WRITEHEADER, $head);
open(my $body, "+>", undef);
Net::Curl::Easy::setopt($easy, CURLOPT_WRITEDATA, $body);
$easy->setopt(CURLOPT_URL, $server->uri . "repeat/$i/abc");
}
my $running = 0;
do {
$multi->wait(1000);
$running = $multi->perform;
t/96-leak.t view on Meta::CPAN
my $n1 = Devel::Leak::NoteSV(my $handle);
test_leak {
my $curl = Net::Curl::Easy->new() or die "cannot curl";
$multi->add_handle($curl);
$curl->setopt(CURLOPT_NOPROGRESS, 1);
$curl->setopt(CURLOPT_FOLLOWLOCATION, 1);
$curl->setopt(CURLOPT_TIMEOUT, 30);
open(my $head, "+>", undef);
Net::Curl::Easy::setopt($curl, CURLOPT_WRITEHEADER, $head);
open(my $body, "+>", undef);
Net::Curl::Easy::setopt($curl, CURLOPT_WRITEDATA, $body);
$curl->setopt(CURLOPT_URL, $url);
$curl->setopt(CURLOPT_SHARE, $share);
eval { $multi->perform() };
if (not $@) {
my $bytes = $curl->getinfo(CURLINFO_SIZE_DOWNLOAD);
my $realurl = $curl->getinfo(CURLINFO_EFFECTIVE_URL);
t/compat-01basic.t view on Meta::CPAN
ok(ref($curl) eq 'WWW::Curl::Easy', 'Curl session looks like an object from the WWW::Curl::Easy module');
ok(! $curl->setopt(CURLOPT_NOPROGRESS, 1), "Setting CURLOPT_NOPROGRESS");
ok(! $curl->setopt(CURLOPT_FOLLOWLOCATION, 1), "Setting CURLOPT_FOLLOWLOCATION");
ok(! $curl->setopt(CURLOPT_TIMEOUT, 30), "Setting CURLOPT_TIMEOUT");
ok(! $curl->setopt(CURLOPT_ENCODING, undef), "Setting CURLOPT_ENCODING to undef");
ok(! $curl->setopt(CURLOPT_RESUME_FROM_LARGE, 0), "Setting CURLOPT_RESUME_FROM_LARGE to 0");
$curl->setopt(CURLOPT_HEADER, 1);
my $head = tempfile();
ok(! $curl->setopt(CURLOPT_WRITEHEADER, $head), "Setting CURLOPT_WRITEHEADER");
my $body = tempfile();
ok(! $curl->setopt(CURLOPT_WRITEDATA,$body), "Setting CURLOPT_WRITEDATA");
ok(! $curl->setopt(CURLOPT_URL, $url), "Setting CURLOPT_URL");
my @myheaders;
$myheaders[0] = "Server: www";
$myheaders[1] = "User-Agent: Perl interface for libcURL";
ok(! $curl->setopt(CURLOPT_HTTPHEADER, \@myheaders), "Setting CURLOPT_HTTPHEADER");
t/compat-02callbacks.t view on Meta::CPAN
# Init the curl session
my $curl = WWW::Curl::Easy->new();
ok($curl, 'Curl session initialize returns something');
ok(ref($curl) eq 'WWW::Curl::Easy', 'Curl session looks like an object from the WWW::Curl::Easy module');
$curl->setopt(CURLOPT_NOPROGRESS, 1);
$curl->setopt(CURLOPT_FOLLOWLOCATION, 1);
$curl->setopt(CURLOPT_TIMEOUT, 30);
my $head = tempfile();
$curl->setopt(CURLOPT_WRITEHEADER, $head);
my $body = tempfile();
$curl->setopt(CURLOPT_FILE,$body);
$curl->setopt(CURLOPT_URL, $url);
my $header_called = 0;
sub header_callback { $header_called = 1; return length($_[0]) };
my $body_called = 0;
sub body_callback { $body_called++;return length($_[0]) };
t/compat-04abort-test.t view on Meta::CPAN
# Init the curl session
my $curl = WWW::Curl::Easy->new();
ok($curl, 'Curl session initialize returns something');
ok(ref($curl) eq 'WWW::Curl::Easy', 'Curl session looks like an object from the WWW::Curl::Easy module');
$curl->setopt(CURLOPT_NOPROGRESS, 1);
$curl->setopt(CURLOPT_FOLLOWLOCATION, 1);
$curl->setopt(CURLOPT_TIMEOUT, 30);
my $head = tempfile();
ok(! $curl->setopt(CURLOPT_WRITEHEADER, $head), "Setting CURLOPT_WRITEHEADER");
my $body = tempfile();
ok(! $curl->setopt(CURLOPT_FILE,$body), "Setting CURLOPT_FILE");
ok(! $curl->setopt(CURLOPT_URL, $url), "Setting CURLOPT_URL");
my $body_abort_called = 0;
sub body_abort_callback { $body_abort_called++; return -1 };
$curl->setopt(CURLOPT_WRITEFUNCTION, \&body_abort_callback);
t/compat-05progress.t view on Meta::CPAN
# Init the curl session
my $curl = WWW::Curl::Easy->new();
ok($curl, 'Curl session initialize returns something');
ok(ref($curl) eq 'WWW::Curl::Easy', 'Curl session looks like an object from the WWW::Curl::Easy module');
ok(! $curl->setopt(CURLOPT_NOPROGRESS, 0), "Setting CURLOPT_NOPROGRESS");
ok(! $curl->setopt(CURLOPT_FOLLOWLOCATION, 1), "Setting CURLOPT_FOLLOWLOCATION");
ok(! $curl->setopt(CURLOPT_TIMEOUT, 30), "Setting CURLOPT_TIMEOUT");
my $head = tempfile();
ok(! $curl->setopt(CURLOPT_WRITEHEADER, $head), "Setting CURLOPT_WRITEHEADER");
my $body = tempfile();
ok(! $curl->setopt(CURLOPT_FILE,$body), "Setting CURLOPT_FILE");
ok(! $curl->setopt(CURLOPT_URL, $url), "Setting CURLOPT_URL");
my @myheaders;
$myheaders[0] = "Server: www";
$myheaders[1] = "User-Agent: Perl interface for libcURL";
ok(! $curl->setopt(CURLOPT_HTTPHEADER, \@myheaders), "Setting CURLOPT_HTTPHEADER");
t/compat-08ssl.t view on Meta::CPAN
# Init the curl session
my $curl = WWW::Curl::Easy->new();
ok($curl, 'Curl session initialize returns something'); #1
ok(ref($curl) eq 'WWW::Curl::Easy', 'Curl session looks like an object from the WWW::Curl::Easy module'); #2
ok(! $curl->setopt(CURLOPT_NOPROGRESS, 1), "Setting CURLOPT_NOPROGRESS"); #3
ok(! $curl->setopt(CURLOPT_FOLLOWLOCATION, 1), "Setting CURLOPT_FOLLOWLOCATION"); #4
ok(! $curl->setopt(CURLOPT_TIMEOUT, 30), "Setting CURLOPT_TIMEOUT"); #5
my $head = tempfile();
ok(! $curl->setopt(CURLOPT_WRITEHEADER, $head), "Setting CURLOPT_WRITEHEADER"); #6
my $body = tempfile();
ok(! $curl->setopt(CURLOPT_FILE, $body), "Setting CURLOPT_FILE"); #7
my @myheaders;
$myheaders[0] = "User-Agent: Verifying SSL functions in WWW::Curl perl interface for libcURL";
$curl->setopt(CURLOPT_HTTPHEADER, \@myheaders);
$curl->setopt(CURLOPT_FORBID_REUSE, 1);
$curl->setopt(CURLOPT_FRESH_CONNECT, 1);
t/compat-09times.t view on Meta::CPAN
# Init the curl session
my $curl = WWW::Curl::Easy->new();
ok($curl, 'Curl session initialize returns something');
ok(ref($curl) eq 'WWW::Curl::Easy', 'Curl session looks like an object from the WWW::Curl::Easy module');
ok(! $curl->setopt(CURLOPT_NOPROGRESS, 1), "Setting CURLOPT_NOPROGRESS");
ok(! $curl->setopt(CURLOPT_FOLLOWLOCATION, 1), "Setting CURLOPT_FOLLOWLOCATION");
ok(! $curl->setopt(CURLOPT_TIMEOUT, 30), "Setting CURLOPT_TIMEOUT");
my $head = tempfile();
ok(! $curl->setopt(CURLOPT_WRITEHEADER, $head), "Setting CURLOPT_WRITEHEADER");
my $body = tempfile();
ok(! $curl->setopt(CURLOPT_FILE, $body), "Setting CURLOPT_FILE");
ok(! $curl->setopt(CURLOPT_URL, $url), "Setting CURLOPT_URL");
my @myheaders;
$myheaders[0] = "Server: www";
$myheaders[1] = "User-Agent: Perl interface for libcURL";
ok(! $curl->setopt(CURLOPT_HTTPHEADER, \@myheaders), "Setting CURLOPT_HTTPHEADER");
t/compat-10errbuf.t view on Meta::CPAN
# Init the curl session
my $curl = WWW::Curl::Easy->new();
ok($curl, 'Curl session initialize returns something');
ok(ref($curl) eq 'WWW::Curl::Easy', 'Curl session looks like an object from the WWW::Curl::Easy module');
ok(! $curl->setopt(CURLOPT_NOPROGRESS, 1), "Setting CURLOPT_NOPROGRESS");
ok(! $curl->setopt(CURLOPT_FOLLOWLOCATION, 1), "Setting CURLOPT_FOLLOWLOCATION");
ok(! $curl->setopt(CURLOPT_TIMEOUT, 30), "Setting CURLOPT_TIMEOUT");
my $head = tempfile();
ok(! $curl->setopt(CURLOPT_WRITEHEADER, $head), "Setting CURLOPT_WRITEHEADER");
my $body = tempfile();
ok(! $curl->setopt(CURLOPT_FILE, $body), "Setting CURLOPT_FILE");
ok(! $curl->setopt(CURLOPT_URL, $url), "Setting CURLOPT_URL");
my $new_error = tempfile();
ok(! $curl->setopt(CURLOPT_STDERR, $new_error), "Setting CURLOPT_STDERR");
# create a (hopefully) bad URL, so we get an error
t/compat-14duphandle.t view on Meta::CPAN
{
# Init the curl session
my $curl = WWW::Curl::Easy->new();
ok($curl, 'Curl session initialize returns something');
ok(ref($curl) eq 'WWW::Curl::Easy', 'Curl session looks like an object from the WWW::Curl::Easy module');
ok(! $curl->setopt(CURLOPT_NOPROGRESS, 1), "Setting CURLOPT_NOPROGRESS");
ok(! $curl->setopt(CURLOPT_FOLLOWLOCATION, 1), "Setting CURLOPT_FOLLOWLOCATION");
ok(! $curl->setopt(CURLOPT_TIMEOUT, 30), "Setting CURLOPT_TIMEOUT");
ok(! $curl->setopt(CURLOPT_WRITEHEADER, $head), "Setting CURLOPT_WRITEHEADER");
ok(! $curl->setopt(CURLOPT_FILE, $body), "Setting CURLOPT_FILE");
ok(! $curl->setopt(CURLOPT_URL, $url), "Setting CURLOPT_URL");
my @myheaders;
$myheaders[0] = "Server: www";
$myheaders[1] = "User-Agent: Perl interface for libcURL";
ok(! $curl->setopt(CURLOPT_HTTPHEADER, \@myheaders), "Setting CURLOPT_HTTPHEADER");
t/compat-15duphandle-callback.t view on Meta::CPAN
{
# Init the curl session
my $curl = WWW::Curl::Easy->new();
ok($curl, 'Curl session initialize returns something'); #1
ok(ref($curl) eq 'WWW::Curl::Easy', 'Curl session looks like an object from the WWW::Curl::Easy module'); #2
ok(! $curl->setopt(CURLOPT_NOPROGRESS, 1), "Setting CURLOPT_NOPROGRESS"); #3
ok(! $curl->setopt(CURLOPT_FOLLOWLOCATION, 1), "Setting CURLOPT_FOLLOWLOCATION"); #4
ok(! $curl->setopt(CURLOPT_TIMEOUT, 30), "Setting CURLOPT_TIMEOUT"); #5
ok(! $curl->setopt(CURLOPT_WRITEHEADER, $head), "Setting CURLOPT_WRITEHEADER"); #6
my $body = tempfile();
ok(! $curl->setopt(CURLOPT_FILE, $body), "Setting CURLOPT_FILE"); #7
my @myheaders;
$myheaders[0] = "Server: www";
$myheaders[1] = "User-Agent: Perl interface for libcURL";
ok(! $curl->setopt(CURLOPT_HTTPHEADER, \@myheaders), "Setting CURLOPT_HTTPHEADER"); #8
t/compat-19multi.t view on Meta::CPAN
my ($rin, $win, $ein, $rout, $wout, $eout);
$rin = $win = $ein = '';
$rin = fhbits($re);
$win = fhbits($wr);
$ein = $rin | $win;
my ($nfound,$timeleft) = select($rin, $win, $ein, 0.02);
}
my $curl = new WWW::Curl::Easy;
$curl->setopt( CURLOPT_URL, $url);
ok(! $curl->setopt(CURLOPT_WRITEHEADER, $header), "Setting CURLOPT_WRITEHEADER");
ok(! $curl->setopt(CURLOPT_WRITEDATA,$body), "Setting CURLOPT_WRITEDATA");
ok(! $curl->setopt(CURLOPT_PRIVATE,"foo"), "Setting CURLOPT_PRIVATE");
my $curl2 = new WWW::Curl::Easy;
$curl2->setopt( CURLOPT_URL, $url);
ok(! $curl2->setopt(CURLOPT_WRITEHEADER, $header2), "Setting CURLOPT_WRITEHEADER");
ok(! $curl2->setopt(CURLOPT_WRITEDATA,$body2), "Setting CURLOPT_WRITEDATA");
ok(! $curl2->setopt(CURLOPT_PRIVATE,42), "Setting CURLOPT_PRIVATE");
my $curlm = new WWW::Curl::Multi;
my @fds = $curlm->fdset;
ok( @fds == 3 && ref($fds[0]) && ref($fds[1]) && ref($fds[2]), "fdset returns 3 references");
ok( ! @{$fds[0]} && ! @{$fds[1]} && !@{$fds[2]} , "The three returned arrayrefs are empty");
$curlm->perform;
@fds = $curlm->fdset;
ok( ! @{$fds[0]} && ! @{$fds[1]} && !@{$fds[2]} , "The three returned arrayrefs are still empty after perform");
t/compat-21write-to-scalar.t view on Meta::CPAN
my $curl = WWW::Curl::Easy->new();
ok(! $curl->setopt(CURLOPT_NOPROGRESS, 1), "Setting CURLOPT_NOPROGRESS");
ok(! $curl->setopt(CURLOPT_FOLLOWLOCATION, 1), "Setting CURLOPT_FOLLOWLOCATION");
ok(! $curl->setopt(CURLOPT_TIMEOUT, 30), "Setting CURLOPT_TIMEOUT");
ok(! $curl->setopt(CURLOPT_ENCODING, undef), "Setting CURLOPT_ENCODING to undef");
ok(! $curl->setopt(CURLOPT_RESUME_FROM_LARGE, 0), "Setting CURLOPT_RESUME_FROM_LARGE to 0");
$curl->setopt(CURLOPT_HEADER, 1);
my $head = '';
ok(! $curl->setopt(CURLOPT_WRITEHEADER, \$head), "Setting CURLOPT_WRITEHEADER");
my $body = '';
ok(! $curl->setopt(CURLOPT_WRITEDATA, \$body), "Setting CURLOPT_WRITEDATA");
ok(! $curl->setopt(CURLOPT_URL, $url), "Setting CURLOPT_URL");
my $retcode = $curl->perform();
ok(! $retcode, "Curl return code ok");
t/old-01basic.t view on Meta::CPAN
ok(ref($curl) eq 'Net::Curl::Easy', 'Curl session looks like an object from the Net::Curl::Easy module');
ok(! $curl->setopt(CURLOPT_NOPROGRESS, 1), "Setting CURLOPT_NOPROGRESS");
ok(! $curl->setopt(CURLOPT_FOLLOWLOCATION, 1), "Setting CURLOPT_FOLLOWLOCATION");
ok(! $curl->setopt(CURLOPT_TIMEOUT, 30), "Setting CURLOPT_TIMEOUT");
ok(! $curl->setopt(CURLOPT_ENCODING, undef), "Setting CURLOPT_ENCODING to undef");
ok(! $curl->setopt(CURLOPT_RESUME_FROM_LARGE, 0), "Setting CURLOPT_RESUME_FROM_LARGE to 0");
$curl->setopt(CURLOPT_HEADER, 1);
my $head = tempfile();
ok(! $curl->setopt(CURLOPT_WRITEHEADER, $head), "Setting CURLOPT_WRITEHEADER");
my $body = tempfile();
ok(! $curl->setopt(CURLOPT_WRITEDATA,$body), "Setting CURLOPT_WRITEDATA");
ok(! $curl->setopt(CURLOPT_URL, $server->uri . "cookie/3" ), "Setting CURLOPT_URL");
my @myheaders;
$myheaders[0] = "Server: www";
$myheaders[1] = "User-Agent: Perl interface for libcURL";
ok(! $curl->setopt(CURLOPT_HTTPHEADER, \@myheaders), "Setting CURLOPT_HTTPHEADER");
t/old-02callbacks.t view on Meta::CPAN
# Init the curl session
my $curl = Net::Curl::Easy->new();
ok($curl, 'Curl session initialize returns something');
ok(ref($curl) eq 'Net::Curl::Easy', 'Curl session looks like an object from the Net::Curl::Easy module');
$curl->setopt(CURLOPT_NOPROGRESS, 1);
$curl->setopt(CURLOPT_FOLLOWLOCATION, 1);
$curl->setopt(CURLOPT_TIMEOUT, 30);
my $head = tempfile();
$curl->setopt(CURLOPT_WRITEHEADER, $head);
my $body = tempfile();
$curl->setopt(CURLOPT_FILE,$body);
$curl->setopt(CURLOPT_URL, $server->uri);
my $header_called = 0;
sub header_callback {
$header_called = 1;
$_[0]->{head} = 1;
t/old-04abort-test.t view on Meta::CPAN
# Init the curl session
my $curl = Net::Curl::Easy->new();
ok($curl, 'Curl session initialize returns something');
ok(ref($curl) eq 'Net::Curl::Easy', 'Curl session looks like an object from the Net::Curl::Easy module');
$curl->setopt(CURLOPT_NOPROGRESS, 1);
$curl->setopt(CURLOPT_FOLLOWLOCATION, 1);
$curl->setopt(CURLOPT_TIMEOUT, 30);
my $head = tempfile();
ok(! $curl->setopt(CURLOPT_WRITEHEADER, $head), "Setting CURLOPT_WRITEHEADER");
my $body = tempfile();
ok(! $curl->setopt(CURLOPT_FILE,$body), "Setting CURLOPT_FILE");
ok(! $curl->setopt(CURLOPT_URL, $server->uri), "Setting CURLOPT_URL");
my $body_abort_called = 0;
sub body_abort_callback { $body_abort_called++; return -1 };
$curl->setopt(CURLOPT_WRITEFUNCTION, \&body_abort_callback);
t/old-05progress.t view on Meta::CPAN
# Init the curl session
my $curl = Net::Curl::Easy->new();
ok($curl, 'Curl session initialize returns something');
ok(ref($curl) eq 'Net::Curl::Easy', 'Curl session looks like an object from the Net::Curl::Easy module');
ok(! $curl->setopt(CURLOPT_NOPROGRESS, 0), "Setting CURLOPT_NOPROGRESS");
ok(! $curl->setopt(CURLOPT_FOLLOWLOCATION, 1), "Setting CURLOPT_FOLLOWLOCATION");
ok(! $curl->setopt(CURLOPT_TIMEOUT, 30), "Setting CURLOPT_TIMEOUT");
my $head = tempfile();
ok(! $curl->setopt(CURLOPT_WRITEHEADER, $head), "Setting CURLOPT_WRITEHEADER");
my $body = tempfile();
ok(! $curl->setopt(CURLOPT_FILE,$body), "Setting CURLOPT_FILE");
ok(! $curl->setopt(CURLOPT_URL, $server->uri), "Setting CURLOPT_URL");
my @myheaders;
$myheaders[0] = "Server: www";
$myheaders[1] = "User-Agent: Perl interface for libcURL";
ok(! $curl->setopt(CURLOPT_HTTPHEADER, \@myheaders), "Setting CURLOPT_HTTPHEADER");
t/old-06http-post.t view on Meta::CPAN
# Init the curl session
my $curl = Net::Curl::Easy->new();
ok($curl, 'Curl session initialize returns something');
ok(ref($curl) eq 'Net::Curl::Easy', 'Curl session looks like an object from the Net::Curl::Easy module');
ok(! $curl->setopt(CURLOPT_NOPROGRESS, 1), "Setting CURLOPT_NOPROGRESS");
ok(! $curl->setopt(CURLOPT_FOLLOWLOCATION, 1), "Setting CURLOPT_FOLLOWLOCATION");
ok(! $curl->setopt(CURLOPT_TIMEOUT, 30), "Setting CURLOPT_TIMEOUT");
my $head = tempfile();
ok(! $curl->setopt(CURLOPT_WRITEHEADER, $head), "Setting CURLOPT_WRITEHEADER");
my $body = tempfile();
ok(! $curl->setopt(CURLOPT_FILE, $body), "Setting CURLOPT_FILE");
ok(! $curl->setopt(CURLOPT_URL, $url), "Setting CURLOPT_URL");
my @myheaders;
$myheaders[0] = "Server: www";
$myheaders[1] = "User-Agent: Perl interface for libcURL";
ok(! $curl->setopt(CURLOPT_HTTPHEADER, \@myheaders), "Setting CURLOPT_HTTPHEADER");
t/old-07ftp-upload.t view on Meta::CPAN
if ($curl == 0) {
print "not ";
}
print "ok ".++$count."\n";
$curl->setopt(CURLOPT_NOPROGRESS, 1);
$curl->setopt(CURLOPT_FOLLOWLOCATION, 1);
$curl->setopt(CURLOPT_TIMEOUT, 30);
open HEAD, ">head.out";
$curl->setopt(CURLOPT_WRITEHEADER, \*HEAD);
print "ok ".++$count."\n";
open BODY, ">body.out";
$curl->setopt(CURLOPT_FILE, \*body);
print "ok ".++$count."\n";
$curl->setopt(CURLOPT_URL, $url);
print "ok ".++$count."\n";
t/old-08ssl.t view on Meta::CPAN
# Init the curl session
my $curl = Net::Curl::Easy->new();
ok($curl, 'Curl session initialize returns something'); #1
ok(ref($curl) eq 'Net::Curl::Easy', 'Curl session looks like an object from the Net::Curl::Easy module'); #2
ok(! $curl->setopt(CURLOPT_NOPROGRESS, 1), "Setting CURLOPT_NOPROGRESS"); #3
ok(! $curl->setopt(CURLOPT_FOLLOWLOCATION, 1), "Setting CURLOPT_FOLLOWLOCATION"); #4
ok(! $curl->setopt(CURLOPT_TIMEOUT, 30), "Setting CURLOPT_TIMEOUT"); #5
my $head = tempfile();
ok(! $curl->setopt(CURLOPT_WRITEHEADER, $head), "Setting CURLOPT_WRITEHEADER"); #6
my $body = tempfile();
ok(! $curl->setopt(CURLOPT_FILE, $body), "Setting CURLOPT_FILE"); #7
my @myheaders;
$myheaders[0] = "User-Agent: Verifying SSL functions in Net::Curl perl interface for libcURL";
$curl->setopt(CURLOPT_HTTPHEADER, \@myheaders);
$curl->setopt(CURLOPT_FORBID_REUSE, 1);
$curl->setopt(CURLOPT_FRESH_CONNECT, 1);
t/old-09times.t view on Meta::CPAN
# Init the curl session
my $curl = Net::Curl::Easy->new();
ok($curl, 'Curl session initialize returns something');
ok(ref($curl) eq 'Net::Curl::Easy', 'Curl session looks like an object from the Net::Curl::Easy module');
ok(! $curl->setopt(CURLOPT_NOPROGRESS, 1), "Setting CURLOPT_NOPROGRESS");
ok(! $curl->setopt(CURLOPT_FOLLOWLOCATION, 1), "Setting CURLOPT_FOLLOWLOCATION");
ok(! $curl->setopt(CURLOPT_TIMEOUT, 30), "Setting CURLOPT_TIMEOUT");
my $head = tempfile();
ok(! $curl->setopt(CURLOPT_WRITEHEADER, $head), "Setting CURLOPT_WRITEHEADER");
my $body = tempfile();
ok(! $curl->setopt(CURLOPT_FILE, $body), "Setting CURLOPT_FILE");
ok(! $curl->setopt(CURLOPT_URL, $server->uri), "Setting CURLOPT_URL");
my @myheaders;
$myheaders[0] = "Server: www";
$myheaders[1] = "User-Agent: Perl interface for libcURL";
ok(! $curl->setopt(CURLOPT_HTTPHEADER, \@myheaders), "Setting CURLOPT_HTTPHEADER");