Net-Curl

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

 - Synced symbols-in-versions from libcurl/7.72.0.

0.45 2020-06-01T17:59:00Z
 [Stanislaw Pusep <stas@sysd.org>]
 - Synced symbols-in-versions from libcurl/7.70.0.

0.44 2020-03-14T09:43:00Z
 [Stanislaw Pusep <stas@sysd.org>]
 - Synced symbols-in-versions from libcurl/7.69.0 (NOW FOR REAL!);
 [Felipe Gasper <felipe@felipegasper.com>]
 - Fix cookies in 02-multi-simple.pl to work with libcurl 7.67+;
 - Fix failure to remove freed easy objects from multi->easies;
 - more explicit warnings;
 - Skip t/cleanup.t in Perl 5.8.9;
 - Use $Config{ccflags} in CCFLAGS to fix compilation on Linux 5.4.12.

0.43 2020-01-20T11:51:00Z
 [Stanislaw Pusep <stas@sysd.org>]
 - Synced symbols-in-versions from libcurl/7.69.0;
 - Recognize SecureTransport as a valid ssl support in t/compat-08ssl.t.
 [Felipe Gasper <felipe@felipegasper.com>]

SIGNATURE  view on Meta::CPAN

SHA256 c848aa172883a78853da4e338e6dcb067ebe39b04af6bee3b8858f2e31ebcb02 lib/Net/Curl/Easy.pm
SHA256 d51326de6047c255c708892d29bbd71ddc93fd5b8cbec1e2c252e1ee500afa72 lib/Net/Curl/Form.pm
SHA256 31866f9c2f1beefecd7e8176f2fbd3d93ee628d2b03dbff23e955f2b0adea846 lib/Net/Curl/Multi.pm
SHA256 90b85bcdf631eccd44a642d6b4dbbc49763e7970cb4eee3e69d121a494466085 lib/Net/Curl/Share.pm
SHA256 40132441344d16c15f99809c34788aa4d26f9f699fb5409ca2c2b06b862f26b4 lib/Net/Curl/examples.pod
SHA256 c8722b1f2855828cf8205413a3d7a7b2b06dc2ad291e5bca5ca9cda1ef51e349 perl_curl.h
SHA256 afab892eb53ae108236b55997525eb37c6e51bcec4545047175dd831471f32c0 perl_curl_multi.h
SHA256 a968488fb7baa582dd1fb60ac28466dcad85b62acd9a4e50e74c0cd0c8331dc2 t/00-info.t
SHA256 6560dc0780c17344a6ea472879fc1a5257954d339c83fb6eb9d72de48c5e829d t/01-constants.t
SHA256 313e5588ca482fc15ec504548634056c159fcc4bfb386e60094e63a932c0bbac t/02-methods.t
SHA256 0b22e41a086a391b273aec1c5c5c57a1bd53c181a5d4321835cb0b0cf35b6559 t/03-cookies.t
SHA256 8e731682a0dc86b8e8a30226f4bb548cb8f7dfab23f1b99b194e87a1c3236446 t/40-callback-opensocket.t
SHA256 51568cbde6892bc48e536512f69a272ed0a6149a790cc74bd9352a30f6c26956 t/50-crash-lastref.t
SHA256 1851970effc531660e4b32cdf00d344db7ba719f4a5a745b6aa7700f893178d4 t/51-crash-destroy-with-callbacks.t
SHA256 27d9a121d79df54f370cecd81780e2cc2242c52158c8c6c6071ed1abda34466e t/52-alter-base.t
SHA256 720871ae528bba229b8a24e9eaa76ccbc72f32bdb764ba5e87f2e479ad2533d8 t/53-crash-destroy-with-callbacks-multi.t
SHA256 a4b9e34a2dfe164b42505b5b0d2c821f8ff0889ad9952ae81350f8d7e4cbcb4c t/54-crash-getinfo-slist.t
SHA256 b04db21d73eb951e85ba5b9c2bcb90c20544efcb60ccbb312ed0bbcb2ef1eb4a t/55-crash-reset.t
SHA256 044bc1054091ba09b3599105fe3a547864d65d9da29704a3f52f2eac74a5f2ff t/60-multi-wait.t
SHA256 af9d233507ec919d1a70f4c5dd0fd43809fea35ba7ad0481d8a2a1b18289a1c1 t/61-multi-wait-other.t
SHA256 fd73b623649cbe9440b3db0c0ddf1eacf414c8aa7bdcd22b5ac85e9986e5b49a t/70-escape-unescape.t

examples/02-multi-simple.pl  view on Meta::CPAN

	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<> );

	return $easy;
}

my $multi = Multi::Simple->new();

my @uri = (
	"http://www.google.com/search?q=perl",
	"http://www.google.com/search?q=curl",
	"http://www.google.com/search?q=perl+curl",
);

{
	# share cookies between all handles
	my $share = Net::Curl::Share->new();
	$share->setopt( CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE );
	$multi->add_handle( easy( shift ( @uri ), $share ) );
}

my $ret = 0;
while ( my ( $msg, $easy, $result ) = $multi->get_one() ) {
	print "\nFinished downloading $easy->{uri}: $result:\n";
	printf "Body is %d bytes long\n", length $easy->{body};
	print "=" x 80 . "\n";

	$ret = 1 if $result;

examples/04-share-threads.pl  view on Meta::CPAN

=head1 Share::Threads

This module shows how one can share http cookies and dns cache between multiple
threads.

=head2 Motivation

Threads are evil, but some people think they are not. I want to make them a
favor and show how bad threads really are.

=head2 Limitations

=over

inc/Test/HTTP/Server.pm  view on Meta::CPAN

	my $body = "";
	if ( not $type or $type eq "head" ) {
		$body .= $self->{head};
	}
	if ( ( not $type or $type eq "body" ) and defined $self->{body} ) {
		$body .= $self->{body};
	}
	return $body;
}

sub cookie
{
	my $self = shift;
	my $num = shift || 1;
	my $template = shift ||
		"test_cookie%n=true; expires=%date(+600); path=/";

	my $expdate = sub {
		my $time = shift;
		$time += time if $time =~ m/^[+-]/;
		return $self->_http_time( $time );
	};
	my @cookies;
	foreach my $n ( 1..$num ) {
		$_ = $template;
		s/%n/$n/;
		s/%date\(\s*([+-]?\d+)\s*\)/$expdate->( $1 )/e;
		push @cookies, $_;
	}
	$self->{out_headers}->{set_cookie} = \@cookies;

	return "Sent $num cookies matching template:\n$template\n";
}

sub repeat
{
	my $self = shift;
	my $num = shift || 1024;
	my $pattern = shift || "=";

	return $pattern x $num;
}

lib/Net/Curl/Easy.pm  view on Meta::CPAN

 package MyBrowser;
 use Net::Curl::Easy qw(/^CURLOPT_/ /^CURLINFO_/);
 use base qw(Net::Curl::Easy);

 sub new
 {
     my $class = shift;
     my $self = $class->SUPER::new( { head => '', body => ''} );
     $self->setopt( CURLOPT_USERAGENT, "MyBrowser v0.1" );
     $self->setopt( CURLOPT_FOLLOWLOCATION, 1 );
     $self->setopt( CURLOPT_COOKIEFILE, "" ); # enable cookie session
     $self->setopt( CURLOPT_FILE, \$self->{body} );
     $self->setopt( CURLOPT_HEADERDATA, \$self->{head} );
     return $self;
 }

 sub get
 {
     my ( $self, $uri ) = @_;
     $self->setopt( CURLOPT_URL, $uri );
     @$self{qw(head body)} = ('', '');

lib/Net/Curl/Share.pm  view on Meta::CPAN


=head1 NAME

Net::Curl::Share - Perl interface for curl_share_* functions

=head1 SYNOPSIS

 use Net::Curl::Share qw(:constants);

 my $share = Net::Curl::Share->new();
 $share->setopt( CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE );
 $share->setopt( CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS );

 $easy_one->setopt( CURLOPT_SHARE() => $share );

 $easy_two->setopt( CURLOPT_SHARE() => $share );

=head1 DESCRIPTION

This module wraps share handle from libcurl and all related functions and
constants. It does not export by default anything, but constants can be

lib/Net/Curl/examples.pod  view on Meta::CPAN

     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<> );

     return $easy;
 }

 my $multi = Multi::Simple->new();

 my @uri = (
     "http://www.google.com/search?q=perl",
     "http://www.google.com/search?q=curl",
     "http://www.google.com/search?q=perl+curl",
 );

 {
     # share cookies between all handles
     my $share = Net::Curl::Share->new();
     $share->setopt( CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE );
     $multi->add_handle( easy( shift ( @uri ), $share ) );
 }

 my $ret = 0;
 while ( my ( $msg, $easy, $result ) = $multi->get_one() ) {
     print "\nFinished downloading $easy->{uri}: $result:\n";
     printf "Body is %d bytes long\n", length $easy->{body};
     print "=" x 80 . "\n";

     $ret = 1 if $result;

t/54-crash-getinfo-slist.t  view on Meta::CPAN

use Test::HTTP::Server;
use Net::Curl::Easy qw(:constants);

local $ENV{no_proxy} = '*';

my $server = Test::HTTP::Server->new;
plan skip_all => "Could not run http server\n" unless $server;
plan tests => 4;

my $easy = Net::Curl::Easy->new();
$easy->setopt( CURLOPT_URL, $server->uri . "cookie" );
$easy->setopt( CURLOPT_COOKIEFILE, '' );
$easy->setopt( CURLOPT_WRITEDATA, \my $body );

my $slist = $easy->getinfo( CURLINFO_COOKIELIST );

pass( "did not die" );
ok( ! defined $slist, 'slist is undef' );

$easy->perform();

$slist = $easy->getinfo( CURLINFO_COOKIELIST );

pass( "did not die" );
is( ref $slist, 'ARRAY', 'slist is an array' );

$" = "\n- ";
#diag( "- @$slist\n" );

t/96-leak.t  view on Meta::CPAN

$multi->setopt(Net::Curl::Multi::CURLMOPT_SOCKETFUNCTION(), sub { 0 });
SKIP: {
    skip q(libcurl/7.29.0 crashes here: http://sourceforge.net/p/curl/bugs/1194/), 1
        if Net::Curl::version_info()->{version} eq q(7.29.0);
    test_leak { my $multi_ = Net::Curl::Multi->new or die }
        q(Net::Curl::Multi->new);
}

Net::Curl::Share->new for 1 .. 5; # warmup
my $share = Net::Curl::Share->new;
$share->setopt(CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
$share->setopt(CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
eval { $share->setopt(CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION) };
test_leak { my $share_ = Net::Curl::Share->new or die }
    q(Net::Curl::Share->new);

my $url = $ENV{CURL_TEST_URL};
$url = qq(file://$Bin/$Script)
    if not defined $url or $url;

my $n1 = Devel::Leak::NoteSV(my $handle);

t/compat-01basic.t  view on Meta::CPAN

	plan skip_all => $@ if $@;
}
use WWW::Curl::Easy;

local $ENV{no_proxy} = '*';

my $server = Test::HTTP::Server->new;
plan skip_all => "Could not run http server\n" unless $server;
plan tests => 18;

my $url = $server->uri . "cookie";

# 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_ENCODING, undef), "Setting CURLOPT_ENCODING to undef");

 view all matches for this distribution
 view release on metacpan -  search on metacpan

( run in 1.581 second using v1.00-cache-2.02-grep-82fe00e-cpan-3b7f77b76a6c )