NAME
WWW::CurlOO::Simple - simplifies WWW::CurlOO::Easy interface
SYNOPSIS
use WWW::CurlOO::Simple;
WWW::CurlOO::Simple->new->get( $uri, \&finished );
sub finished
{
my ( $curl, $result ) = @_;
print "document body: $curl->{body}\n";
# reuse connection to get another file
$curl->get( '/other_file', \&finished2 );
}
sub finished2 { }
CONSTRUCTOR
- new( [PERMANENT_OPTIONS] )
-
Creates new WWW::CurlOO::Simple object.
my $curl = WWW::CurlOO::Simple->new( timeout => 60 );
METHODS
- setopt( NAME, VALUE, [TEMPORARY] )
-
Set some option. Either permanently or only for next request if TEMPORARY is true.
- setopts( PERMANENT_OPTIONS )
-
Set multiple options, permanently.
- setopts_temp( TEMPORARY_OPTIONS )
-
Set multiple options, only for next request.
- getinfo( NAME )
-
Get connection information.
my $value = $curl->getinfo( 'effective_url' );
- getinfos( INFO_NAMES )
-
Get multiple getinfo values.
my ( $v1, $v2 ) ) $curl->getinfos( 'name1', 'name2' );
- ua
-
Get parent WWW::CurlOO::Simple::UserAgent object.
- get( URI, CALLBACK, [TEMPORARY_OPTIONS] )
-
Issue a GET request. CALLBACK will be called upon finishing with two arguments: WWW::CurlOO::Simple object and the result value. If URI is incomplete, full uri will be constructed using $curl->{referer} as base. WWW::CurlOO::Simple updates $curl->{referer} after every request. TEMPORARY_OPTIONS will be set for this request only.
$curl->get( "http://full.uri/", sub { my $curl = shift; my $result = shift; die "get() failed: $result\n" unless $result == 0; $curl->get( "/partial/uri", sub {} ); } );
- head( URI, CALLBACK, [TEMPORARY_OPTIONS] )
-
Issue a HEAD request. Otherwise it is exactly the same as get().
- post( URI, CALLBACK, POST, [TEMPORARY_OPTIONS] )
-
Issue a POST request. POST value can be either a scalar, in which case it will be sent literally, a HASHREF - will be uri-encoded, or a WWW::CurlOO::Form object (WWW::CurlOO::Simple::Form is OK as well).
$curl->post( $uri, \&finished, { username => "foo", password => "bar" } );
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).
Names for getinfo can also be either CURLINFO_* values or literal names without CURLINFO_ preffix.
SEE ALSO
WWW::CurlOO::Simple::UserAgent WWW::CurlOO::Simple::Async WWW::CurlOO::Easy
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.