NAME
WWW::CurlOO::Simple::UserAgent - share some data between multiple WWW::CurlOO::Simple objects
SYNOPSIS
use WWW::CurlOO::Simple::UserAgent;
# options for all out user agents
WWW::CurlOO::Simple::UserAgent->setopt(
useragent => "My::Downloader",
);
# this one uses socks for connection
my $ua = WWW::CurlOO::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";
}
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 WWW::CurlOO::Simple::UserAgent object.
my $ua = WWW::CurlOO::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 WWW::CurlOO::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 WWW::CurlOO::Easy), or literal names, preferably in lower case, without the CURLOPT_ preffix. For description of available options see curl_easy_setopt(3).
SEE ALSO
WWW::CurlOO::Simple WWW::CurlOO::Simple::Async WWW::CurlOO::Easy WWW::CurlOO::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.