NAME
Net::Curl::Simple::UserAgent - share some data between multiple Net::Curl::Simple objects
SYNOPSIS
use Net::Curl::Simple::UserAgent;
# options for all out user agents
Net::Curl::Simple::UserAgent->setopt(
useragent => "My::Downloader",
);
# this one uses socks for connection
my $ua = Net::Curl::Simple::UserAgent->new(
proxy => "socks5://localhost:9980/",
);
# those two requests share cookies and options set before
$ua->curl()->get( $uri, \&finished );
$ua->curl()->get( $uri2, \&finished );
sub finished
{
my ( $curl, $result ) = @_;
print "document body: $curl->{body}\n";
}
DESCRIPTION
Net::Curl::Simple::UserAgent
provides a method to preset some options for multiple Net::Curl::Simple objects and allow them to share cookies.
SPECIAL METHODS
If setopt() or setopts() is called with package name and not an object, it will alter default UserAgent options. All newely-created user agents will share those options.
CONSTRUCTOR
- new( [%GLOBAL_OPTIONS] )
-
Creates new Net::Curl::Simple::UserAgent object.
my $ua = Net::Curl::Simple::UserAgent->new( timeout => 60 );
METHODS
- setopt( NAME, VALUE )
-
Set option for all new curl instances. It will not alter any curl instances created already.
- setopts( %GLOBAL_OPTIONS )
-
Set multiple curl options.
- curl( [%PERMANENT_OPTIONS] )
-
Get new Net::Curl::Simple instance attached to this user agent. Options will be passed to new() constructor and will not affect any other instances.
OPTIONS
Options can be either CURLOPT_* values (import them from Net::Curl::Easy), or literal names, preferably in lower case, without the CURLOPT_ preffix. The second method is preferred. For description of available options see curl_easy_setopt(3).
SEE ALSO
Net::Curl::Simple, Net::Curl::Simple::examples, Net::Curl::Easy, Net::Curl::Share
COPYRIGHT
Copyright (c) 2011 Przemyslaw Iskra <sparky at pld-linux.org>.
This program is free software; you can redistribute it and/or modify it under the same terms as perl itself.