diff options
author | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-12 15:16:01 +0900 |
---|---|---|
committer | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-12 15:16:01 +0900 |
commit | 0034f59c7ed77eb8f8fe1ec082749d8520e3412e (patch) | |
tree | 6b318e64217938d6cd8ca074214778d2db99de84 /t/14duphandle.t | |
parent | 3555375b5b187f5eb25bc6673e2479d54f20ada3 (diff) | |
download | perl-WWW-Curl-0034f59c7ed77eb8f8fe1ec082749d8520e3412e.tar.gz perl-WWW-Curl-0034f59c7ed77eb8f8fe1ec082749d8520e3412e.tar.bz2 perl-WWW-Curl-0034f59c7ed77eb8f8fe1ec082749d8520e3412e.zip |
Tizen 2.1 basesubmit/tizen_2.1/20130423.103931submit/tizen/20130517.051924accepted/tizen_2.1/20130423.151409accepted/tizen/20130520.1018262.1b_releasetizen_2.1
Diffstat (limited to 't/14duphandle.t')
-rw-r--r-- | t/14duphandle.t | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/t/14duphandle.t b/t/14duphandle.t new file mode 100644 index 0000000..f56ac57 --- /dev/null +++ b/t/14duphandle.t @@ -0,0 +1,71 @@ +#!perl + +use strict; +use warnings; +use lib 'inc'; +use lib 'blib/lib'; +use lib 'blib/arch'; +use Test::More tests => 17; +use File::Temp qw/tempfile/; + +BEGIN { use_ok( 'WWW::Curl::Easy' ); } + +my $url = $ENV{CURL_TEST_URL} || "http://www.google.com"; + +{ +my $other_handle; +my $head = tempfile(); +my $body = tempfile(); + + { + # 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"); + + # duplicate the handle + $other_handle = $curl->duphandle(); + ok ($other_handle && ref($other_handle) eq 'WWW::Curl::Easy', "Duplicated handle seems to be an object in the right namespace"); + + foreach my $x ($other_handle,$curl) { + my $retcode = $x->perform(); + ok(!$retcode, "Perform returns without an error"); + if ($retcode == 0) { + my $bytes = $x->getinfo(CURLINFO_SIZE_DOWNLOAD); + my $realurl = $x->getinfo(CURLINFO_EFFECTIVE_URL); + my $httpcode = $x->getinfo(CURLINFO_HTTP_CODE); + } + } + } + +ok(1, "Survived original curl handle DESTROY"); + +ok(! $other_handle->setopt(CURLOPT_URL, $url), "Setting CURLOPT_URL"); +my $retcode = $other_handle->perform(); +ok(!$retcode, "Perform returns without an error"); +if ($retcode == 0) { + my $bytes=$other_handle->getinfo(CURLINFO_SIZE_DOWNLOAD); + my $realurl=$other_handle->getinfo(CURLINFO_EFFECTIVE_URL); + my $httpcode=$other_handle->getinfo(CURLINFO_HTTP_CODE); +} + + + +} +ok(1, "Survived dup curl handle DESTROY"); +exit; |