aboutsummaryrefslogtreecommitdiff
path: root/perl/Curl_easy/t
diff options
context:
space:
mode:
Diffstat (limited to 'perl/Curl_easy/t')
-rw-r--r--perl/Curl_easy/t/00constants.t38
-rw-r--r--perl/Curl_easy/t/01basic.t93
-rw-r--r--perl/Curl_easy/t/02header-callback.t89
-rw-r--r--perl/Curl_easy/t/03body-callback.t105
-rw-r--r--perl/Curl_easy/t/04abort-test.t87
-rw-r--r--perl/Curl_easy/t/05progress.t99
-rw-r--r--perl/Curl_easy/t/06http-post.t99
-rw-r--r--perl/Curl_easy/t/07ftp-upload.t129
-rw-r--r--perl/Curl_easy/t/08ssl.t98
-rw-r--r--perl/Curl_easy/t/Makefile.am2
10 files changed, 839 insertions, 0 deletions
diff --git a/perl/Curl_easy/t/00constants.t b/perl/Curl_easy/t/00constants.t
new file mode 100644
index 000000000..2ef15453e
--- /dev/null
+++ b/perl/Curl_easy/t/00constants.t
@@ -0,0 +1,38 @@
+
+# Test script for Perl extension Curl::easy.
+# Check out the file README for more info.
+
+# Before `make install' is performed this script should be runnable with
+# `make test'. After `make install' it should work as `perl thisfile.t'
+
+######################### We start with some black magic to print on failure.
+
+# Change 1..1 below to 1..last_test_to_print .
+# (It may become useful if the test is moved to ./t subdirectory.)
+use Benchmark;
+use strict;
+
+BEGIN { $| = 1; print "1..2\n"; }
+END {print "not ok 1\n" unless $::loaded;}
+use Curl::easy;
+
+$::loaded = 1;
+print "ok 1\n";
+
+######################## End of black magic.
+
+# Insert your test code below (better if it prints "ok 13"
+# (correspondingly "not ok 13") depending on the success of chunk 13
+# of the test code):
+
+my $count=1;
+
+print STDERR "Testing curl version ",&Curl::easy::version(),"\n";
+
+if (CURLOPT_URL != 10000+2) {
+ print "not ";
+}
+
+print "ok ".++$count;
+
+exit;
diff --git a/perl/Curl_easy/t/01basic.t b/perl/Curl_easy/t/01basic.t
new file mode 100644
index 000000000..79a6e8a24
--- /dev/null
+++ b/perl/Curl_easy/t/01basic.t
@@ -0,0 +1,93 @@
+# Test script for Perl extension Curl::easy.
+# Check out the file README for more info.
+
+# Before `make install' is performed this script should be runnable with
+# `make t/thisfile.t'. After `make install' it should work as `perl thisfile.t'
+
+######################### We start with some black magic to print on failure.
+
+# Change 1..1 below to 1..last_test_to_print .
+use strict;
+
+BEGIN { $| = 1; print "1..6\n"; }
+END {print "not ok 1\n" unless $::loaded;}
+use Curl::easy;
+
+$::loaded = 1;
+print "ok 1\n";
+
+######################### End of black magic.
+
+# Insert your test code below (better if it prints "ok 13"
+# (correspondingly "not ok 13") depending on the success of chunk 13
+# of the test code):
+
+my $count=1;
+
+# Read URL to get
+my $defurl = "http://localhost/cgi-bin/printenv";
+my $url;
+if (defined ($ENV{CURL_TEST_URL})) {
+ $url=$ENV{CURL_TEST_URL};
+} else {
+$url = "";
+print "Please enter an URL to fetch [$defurl]: ";
+$url = <STDIN>;
+if ($url =~ /^\s*\n/) {
+ $url = $defurl;
+}
+}
+
+# Init the curl session
+my $curl = Curl::easy::init();
+if ($curl == 0) {
+ print "not ";
+}
+print "ok ".++$count."\n";
+
+Curl::easy::setopt($curl, CURLOPT_NOPROGRESS, 1);
+Curl::easy::setopt($curl, CURLOPT_MUTE, 1);
+Curl::easy::setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
+Curl::easy::setopt($curl, CURLOPT_TIMEOUT, 30);
+
+open HEAD, ">head.out";
+Curl::easy::setopt($curl, CURLOPT_WRITEHEADER, *HEAD);
+print "ok ".++$count."\n";
+
+open BODY, ">body.out";
+Curl::easy::setopt($curl, CURLOPT_FILE,*BODY);
+print "ok ".++$count."\n";
+
+my $errbuf;
+Curl::easy::setopt($curl, CURLOPT_ERRORBUFFER, "errbuf");
+print "ok ".++$count."\n";
+
+Curl::easy::setopt($curl, CURLOPT_URL, $url);
+
+print "ok ".++$count."\n";
+# Add some additional headers to the http-request:
+my @myheaders;
+$myheaders[0] = "Server: www";
+$myheaders[1] = "User-Agent: Perl interface for libcURL";
+Curl::easy::setopt($curl, CURLOPT_HTTPHEADER, \@myheaders);
+
+my $bytes;
+my $realurl;
+my $httpcode;
+
+# Go get it
+my $retcode=Curl::easy::perform($curl);
+if ($retcode == 0) {
+ Curl::easy::getinfo($curl, CURLINFO_SIZE_DOWNLOAD, $bytes);
+ print STDERR "$bytes bytes read ";
+ Curl::easy::getinfo($curl, CURLINFO_EFFECTIVE_URL, $realurl);
+ Curl::easy::getinfo($curl, CURLINFO_HTTP_CODE, $httpcode);
+ print STDERR "effective fetched url (http code: $httpcode) was: $url ";
+} else {
+ # We can acces the error message in $errbuf here
+ print STDERR "$retcode / '$errbuf'\n";
+ print "not ";
+}
+print "ok ".++$count."\n";
+
+exit;
diff --git a/perl/Curl_easy/t/02header-callback.t b/perl/Curl_easy/t/02header-callback.t
new file mode 100644
index 000000000..94a745c39
--- /dev/null
+++ b/perl/Curl_easy/t/02header-callback.t
@@ -0,0 +1,89 @@
+# Test script for Perl extension Curl::easy.
+# Check out the file README for more info.
+
+# Before `make install' is performed this script should be runnable with
+# `make t/thisfile.t'. After `make install' it should work as `perl thisfile.t'
+
+######################### We start with some black magic to print on failure.
+
+# Change 1..1 below to 1..last_test_to_print .
+use strict;
+
+BEGIN { $| = 1; print "1..9\n"; }
+END {print "not ok 1\n" unless $::loaded;}
+use Curl::easy;
+
+$::loaded = 1;
+print "ok 1\n";
+
+######################### End of black magic.
+
+# Insert your test code below (better if it prints "ok 13"
+# (correspondingly "not ok 13") depending on the success of chunk 13
+# of the test code):
+
+my $count=1;
+
+# Read URL to get
+my $defurl = "http://localhost/cgi-bin/printenv";
+my $url;
+if (defined ($ENV{CURL_TEST_URL})) {
+ $url=$ENV{CURL_TEST_URL};
+} else {
+$url = "";
+print "Please enter an URL to fetch [$defurl]: ";
+$url = <STDIN>;
+if ($url =~ /^\s*\n/) {
+ $url = $defurl;
+}
+}
+
+# Init the curl session
+my $curl = Curl::easy::init();
+if ($curl == 0) {
+ print "not ";
+}
+print "ok ".++$count."\n";
+
+Curl::easy::setopt($curl, CURLOPT_NOPROGRESS, 1);
+Curl::easy::setopt($curl, CURLOPT_MUTE, 1);
+Curl::easy::setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
+Curl::easy::setopt($curl, CURLOPT_TIMEOUT, 30);
+
+open HEAD, ">head.out";
+Curl::easy::setopt($curl, CURLOPT_WRITEHEADER, *HEAD);
+print "ok ".++$count."\n";
+
+open BODY, ">body.out";
+Curl::easy::setopt($curl, CURLOPT_FILE,*BODY);
+print "ok ".++$count."\n";
+
+my $errbuf;
+Curl::easy::setopt($curl, CURLOPT_ERRORBUFFER, "errbuf");
+print "ok ".++$count."\n";
+
+Curl::easy::setopt($curl, CURLOPT_URL, $url);
+
+print "ok ".++$count."\n";
+# The header callback will only be called if your libcurl has the
+# CURLOPT_HEADERFUNCTION supported, otherwise your headers
+# go to CURLOPT_WRITEFUNCTION instead...
+#
+
+my $header_called=0;
+sub header_callback { print STDERR "header callback called\n"; $header_called=1; return length($_[0])};
+
+# test for sub reference and head callback
+Curl::easy::setopt($curl, CURLOPT_HEADERFUNCTION, \&header_callback);
+print "ok ".++$count."\n";
+
+if (Curl::easy::perform($curl) != 0) {
+ print "not ";
+};
+print "ok ".++$count."\n";
+
+print STDERR "next test will fail on libcurl < 7.7.2\n";
+print "not " if (!$header_called); # ok if you have a libcurl <7.7.2
+print "ok ".++$count."\n";
+
+exit;
diff --git a/perl/Curl_easy/t/03body-callback.t b/perl/Curl_easy/t/03body-callback.t
new file mode 100644
index 000000000..94786f507
--- /dev/null
+++ b/perl/Curl_easy/t/03body-callback.t
@@ -0,0 +1,105 @@
+# Test script for Perl extension Curl::easy.
+# Check out the file README for more info.
+
+# Before `make install' is performed this script should be runnable with
+# `make t/thisfile.t'. After `make install' it should work as `perl thisfile.t'
+
+######################### We start with some black magic to print on failure.
+
+# Change 1..1 below to 1..last_test_to_print .
+use strict;
+
+BEGIN { $| = 1; print "1..9\n"; }
+END {print "not ok 1\n" unless $::loaded;}
+use Curl::easy;
+
+$::loaded = 1;
+print "ok 1\n";
+
+######################### End of black magic.
+
+# Insert your test code below (better if it prints "ok 13"
+# (correspondingly "not ok 13") depending on the success of chunk 13
+# of the test code):
+
+my $count=1;
+
+# Read URL to get
+my $defurl = "http://localhost/cgi-bin/printenv";
+my $url;
+if (defined ($ENV{CURL_TEST_URL})) {
+ $url=$ENV{CURL_TEST_URL};
+} else {
+$url = "";
+print "Please enter an URL to fetch [$defurl]: ";
+$url = <STDIN>;
+if ($url =~ /^\s*\n/) {
+ $url = $defurl;
+}
+}
+
+# Init the curl session
+my $curl = Curl::easy::init();
+if ($curl == 0) {
+ print "not ";
+}
+print "ok ".++$count."\n";
+
+Curl::easy::setopt($curl, CURLOPT_NOPROGRESS, 1);
+Curl::easy::setopt($curl, CURLOPT_MUTE, 1);
+Curl::easy::setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
+Curl::easy::setopt($curl, CURLOPT_TIMEOUT, 30);
+
+open HEAD, ">head.out";
+Curl::easy::setopt($curl, CURLOPT_WRITEHEADER, *HEAD);
+print "ok ".++$count."\n";
+
+open BODY, ">body.out";
+Curl::easy::setopt($curl, CURLOPT_FILE,*BODY);
+print "ok ".++$count."\n";
+
+my $errbuf;
+Curl::easy::setopt($curl, CURLOPT_ERRORBUFFER, "errbuf");
+print "ok ".++$count."\n";
+
+Curl::easy::setopt($curl, CURLOPT_URL, $url);
+
+print "ok ".++$count."\n";
+
+# The header callback will only be called if your libcurl has the
+# CURLOPT_HEADERFUNCTION supported, otherwise your headers
+# go to CURLOPT_WRITEFUNCTION instead...
+#
+
+my $header_called=0;
+sub header_callback { print STDERR "header callback called\n"; $header_called=1; return length($_[0])};
+
+# test for sub reference and head callback
+Curl::easy::setopt($curl, CURLOPT_HEADERFUNCTION, \&header_callback);
+
+my $body_called=0;
+sub body_callback {
+ my ($chunk,$handle)=@_;
+ print STDERR "body callback called with ",length($chunk)," bytes\n";
+ print STDERR "data=$chunk\n";
+ $body_called++;
+ return length($chunk); # OK
+}
+
+
+# test for ref to sub and body callback
+my $body_ref=\&body_callback;
+Curl::easy::setopt($curl, CURLOPT_WRITEFUNCTION, $body_ref);
+
+if (Curl::easy::perform($curl) != 0) {
+ print "not ";
+};
+print "ok ".++$count."\n";
+
+
+print STDERR "next test will fail on libcurl < 7.7.2\n";
+print STDERR "not " if (!$header_called); # ok if you have a libcurl <7.7.2
+print "ok ".++$count."\n";
+
+print "not " if (!$body_called);
+print "ok ".++$count."\n";
diff --git a/perl/Curl_easy/t/04abort-test.t b/perl/Curl_easy/t/04abort-test.t
new file mode 100644
index 000000000..c3d71bb02
--- /dev/null
+++ b/perl/Curl_easy/t/04abort-test.t
@@ -0,0 +1,87 @@
+# Test script for Perl extension Curl::easy.
+# Check out the file README for more info.
+
+# Before `make install' is performed this script should be runnable with
+# `make t/thisfile.t'. After `make install' it should work as `perl thisfile.t'
+
+######################### We start with some black magic to print on failure.
+
+# Change 1..1 below to 1..last_test_to_print .
+use strict;
+
+BEGIN { $| = 1; print "1..8\n"; }
+END {print "not ok 1\n" unless $::loaded;}
+use Curl::easy;
+
+$::loaded = 1;
+print "ok 1\n";
+
+######################### End of black magic.
+
+# Insert your test code below (better if it prints "ok 13"
+# (correspondingly "not ok 13") depending on the success of chunk 13
+# of the test code):
+
+my $count=1;
+
+# Read URL to get
+my $defurl = "http://localhost/cgi-bin/printenv";
+my $url;
+if (defined ($ENV{CURL_TEST_URL})) {
+ $url=$ENV{CURL_TEST_URL};
+} else {
+$url = "";
+print "Please enter an URL to fetch [$defurl]: ";
+$url = <STDIN>;
+if ($url =~ /^\s*\n/) {
+ $url = $defurl;
+}
+}
+
+# Init the curl session
+my $curl = Curl::easy::init();
+if ($curl == 0) {
+ print "not ";
+}
+print "ok ".++$count."\n";
+
+Curl::easy::setopt($curl, CURLOPT_NOPROGRESS, 1);
+Curl::easy::setopt($curl, CURLOPT_MUTE, 1);
+Curl::easy::setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
+Curl::easy::setopt($curl, CURLOPT_TIMEOUT, 30);
+
+open HEAD, ">head.out";
+Curl::easy::setopt($curl, CURLOPT_WRITEHEADER, *HEAD);
+print "ok ".++$count."\n";
+
+open BODY, ">body.out";
+Curl::easy::setopt($curl, CURLOPT_FILE,*BODY);
+print "ok ".++$count."\n";
+
+my $errbuf;
+Curl::easy::setopt($curl, CURLOPT_ERRORBUFFER, "errbuf");
+print "ok ".++$count."\n";
+
+Curl::easy::setopt($curl, CURLOPT_URL, $url);
+
+print "ok ".++$count."\n";
+
+my $body_abort_called=0;
+sub body_abort_callback {
+ my ($chunk,$sv)=@_;
+ print STDERR "body abort callback called with ",length($chunk)," bytes\n";
+ $body_abort_called++;
+ return -1; # signal a failure
+}
+
+# test we can abort a request mid-way
+my $body_abort_ref=\&body_abort_callback;
+Curl::easy::setopt($curl, CURLOPT_WRITEFUNCTION, $body_abort_ref);
+
+if (Curl::easy::perform($curl) == 0) { # reverse test - this should have failed
+ print "not ";
+};
+print "ok ".++$count."\n";
+
+print "not " if (!$body_abort_called); # should have been called
+print "ok ".++$count."\n";
diff --git a/perl/Curl_easy/t/05progress.t b/perl/Curl_easy/t/05progress.t
new file mode 100644
index 000000000..ffcdb8036
--- /dev/null
+++ b/perl/Curl_easy/t/05progress.t
@@ -0,0 +1,99 @@
+# Test script for Perl extension Curl::easy.
+# Check out the file README for more info.
+
+# Before `make install' is performed this script should be runnable with
+# `make t/thisfile.t'. After `make install' it should work as `perl thisfile.t'
+
+######################### We start with some black magic to print on failure.
+
+# Change 1..1 below to 1..last_test_to_print .
+use strict;
+
+BEGIN { $| = 1; print "1..9\n"; }
+END {print "not ok 1\n" unless $::loaded;}
+use Curl::easy;
+
+$::loaded = 1;
+print "ok 1\n";
+
+######################### End of black magic.
+
+# Insert your test code below (better if it prints "ok 13"
+# (correspondingly "not ok 13") depending on the success of chunk 13
+# of the test code):
+
+my $count=1;
+
+# Read URL to get
+my $defurl = "http://localhost/cgi-bin/printenv";
+my $url;
+if (defined ($ENV{CURL_TEST_URL})) {
+ $url=$ENV{CURL_TEST_URL};
+} else {
+$url = "";
+print "Please enter an URL to fetch [$defurl]: ";
+$url = <STDIN>;
+if ($url =~ /^\s*\n/) {
+ $url = $defurl;
+}
+}
+
+# Init the curl session
+my $curl = Curl::easy::init();
+if ($curl == 0) {
+ print "not ";
+}
+print "ok ".++$count."\n";
+
+Curl::easy::setopt($curl, CURLOPT_NOPROGRESS, 1);
+Curl::easy::setopt($curl, CURLOPT_MUTE, 1);
+Curl::easy::setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
+Curl::easy::setopt($curl, CURLOPT_TIMEOUT, 30);
+
+open HEAD, ">head.out";
+Curl::easy::setopt($curl, CURLOPT_WRITEHEADER, *HEAD);
+print "ok ".++$count."\n";
+
+open BODY, ">body.out";
+Curl::easy::setopt($curl, CURLOPT_FILE,*BODY);
+print "ok ".++$count."\n";
+
+my $errbuf;
+Curl::easy::setopt($curl, CURLOPT_ERRORBUFFER, "errbuf");
+print "ok ".++$count."\n";
+
+Curl::easy::setopt($curl, CURLOPT_URL, $url);
+
+print "ok ".++$count."\n";
+
+Curl::easy::setopt($curl, CURLOPT_NOPROGRESS, 0);
+print "ok ".++$count."\n";
+
+# inline progress function
+# tests for inline subs and progress callback
+# - progress callback must return 'true' on each call.
+
+my $progress_called=0;
+sub prog_callb
+{
+ my ($clientp,$dltotal,$dlnow,$ultotal,$ulnow)=@_;
+ print STDERR "\nperl progress_callback has been called!\n";
+ print STDERR "clientp: $clientp, dltotal: $dltotal, dlnow: $dlnow, ultotal: $ultotal, ";
+ print STDERR "ulnow: $ulnow\n";
+ $progress_called++;
+ return 0;
+}
+
+Curl::easy::setopt($curl, CURLOPT_PROGRESSFUNCTION, \&prog_callb);
+
+# Turn progress meter back on - this doesn't work in older libcurls - once its off, its off.
+Curl::easy::setopt($curl, CURLOPT_NOPROGRESS, 0);
+
+if (Curl::easy::perform($curl) != 0) {
+ print "not ";
+};
+print "ok ".++$count."\n";
+
+print "not " if (!$progress_called);
+print "ok ".++$count."\n";
+
diff --git a/perl/Curl_easy/t/06http-post.t b/perl/Curl_easy/t/06http-post.t
new file mode 100644
index 000000000..c38cab98d
--- /dev/null
+++ b/perl/Curl_easy/t/06http-post.t
@@ -0,0 +1,99 @@
+# Test script for Perl extension Curl::easy.
+# Check out the file README for more info.
+
+# Before `make install' is performed this script should be runnable with
+# `make t/thisfile.t'. After `make install' it should work as `perl thisfile.t'
+
+######################### We start with some black magic to print on failure.
+
+# Change 1..1 below to 1..last_test_to_print .
+use strict;
+
+BEGIN { $| = 1; print "1..7\n"; }
+END {print "not ok 1\n" unless $::loaded;}
+use Curl::easy;
+
+$::loaded = 1;
+print "ok 1\n";
+
+######################### End of black magic.
+
+# Insert your test code below (better if it prints "ok 13"
+# (correspondingly "not ok 13") depending on the success of chunk 13
+# of the test code):
+
+my $count=1;
+
+# Read URL to get
+my $defurl = "http://localhost/cgi-bin/printenv";
+my $url;
+if (defined ($ENV{CURL_TEST_URL})) {
+ $url=$ENV{CURL_TEST_URL};
+} else {
+$url = "";
+print "Please enter an URL to fetch [$defurl]: ";
+$url = <STDIN>;
+if ($url =~ /^\s*\n/) {
+ $url = $defurl;
+}
+}
+
+# Init the curl session
+my $curl = Curl::easy::init();
+if ($curl == 0) {
+ print "not ";
+}
+print "ok ".++$count."\n";
+
+Curl::easy::setopt($curl, CURLOPT_NOPROGRESS, 1);
+Curl::easy::setopt($curl, CURLOPT_MUTE, 1);
+Curl::easy::setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
+Curl::easy::setopt($curl, CURLOPT_TIMEOUT, 30);
+
+open HEAD, ">head.out";
+Curl::easy::setopt($curl, CURLOPT_WRITEHEADER, *HEAD);
+print "ok ".++$count."\n";
+
+open BODY, ">body.out";
+Curl::easy::setopt($curl, CURLOPT_FILE,*BODY);
+print "ok ".++$count."\n";
+
+my $errbuf;
+Curl::easy::setopt($curl, CURLOPT_ERRORBUFFER, "errbuf");
+print "ok ".++$count."\n";
+
+Curl::easy::setopt($curl, CURLOPT_URL, $url);
+
+print "ok ".++$count."\n";
+
+my $read_max=1000;
+
+sub read_callb
+{
+ my ($maxlen,$sv)=@_;
+ print STDERR "\nperl read_callback has been called!\n";
+ print STDERR "max data size: $maxlen - need $read_max bytes\n";
+ if ($read_max > 0) {
+ my $len=int($read_max/3)+1;
+ my $data = chr(ord('A')+rand(26))x$len;
+ print STDERR "generated max/3=", int($read_max/3)+1, " characters to be uploaded - $data.\n";
+ $read_max=$read_max-length($data);
+ return $data;
+ } else {
+ return "";
+ }
+}
+
+#
+# test post/read callback functions - requires a url which accepts posts, or it fails!
+#
+
+Curl::easy::setopt($curl,CURLOPT_READFUNCTION,\&read_callb);
+Curl::easy::setopt($curl,CURLOPT_INFILESIZE,$read_max );
+Curl::easy::setopt($curl,CURLOPT_UPLOAD,1 );
+Curl::easy::setopt($curl,CURLOPT_CUSTOMREQUEST,"POST" );
+
+if (Curl::easy::perform($curl) != 0) {
+ print "not ";
+};
+print "ok ".++$count."\n";
diff --git a/perl/Curl_easy/t/07ftp-upload.t b/perl/Curl_easy/t/07ftp-upload.t
new file mode 100644
index 000000000..c23a180d2
--- /dev/null
+++ b/perl/Curl_easy/t/07ftp-upload.t
@@ -0,0 +1,129 @@
+# Test script for Perl extension Curl::easy.
+# Check out the file README for more info.
+
+# Before `make install' is performed this script should be runnable with
+# `make t/thisfile.t'. After `make install' it should work as `perl thisfile.t'
+
+######################### We start with some black magic to print on failure.
+
+# Change 1..1 below to 1..last_test_to_print .
+use strict;
+
+BEGIN { $| = 1; print "1..10\n"; }
+END {print "not ok 1\n" unless $::loaded;}
+use Curl::easy;
+
+$::loaded = 1;
+print "ok 1\n";
+
+######################### End of black magic.
+
+# Insert your test code below (better if it prints "ok 13"
+# (correspondingly "not ok 13") depending on the success of chunk 13
+# of the test code):
+
+my $count=1;
+
+# Read URL to get
+my $defurl = "ftp://user\@localhost//tmp/blah";
+my $url;
+if (defined ($ENV{CURL_TEST_URL_FTP})) {
+ $url=$ENV{CURL_TEST_URL_FTP};
+};# else {
+#$url = "";
+#print "Please enter an URL to fetch [$defurl]: ";
+#$url = <STDIN>;
+#if ($url =~ /^\s*\n/) {
+ $url = $defurl;
+#}
+#}
+
+# Init the curl session
+my $curl = Curl::easy::init();
+if ($curl == 0) {
+ print "not ";
+}
+print "ok ".++$count."\n";
+
+Curl::easy::setopt($curl, CURLOPT_NOPROGRESS, 1);
+Curl::easy::setopt($curl, CURLOPT_MUTE, 1);
+Curl::easy::setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
+Curl::easy::setopt($curl, CURLOPT_TIMEOUT, 30);
+
+open HEAD, ">head.out";
+Curl::easy::setopt($curl, CURLOPT_WRITEHEADER, *HEAD);
+print "ok ".++$count."\n";
+
+open BODY, ">body.out";
+Curl::easy::setopt($curl, CURLOPT_FILE,*BODY);
+print "ok ".++$count."\n";
+
+my $errbuf;
+Curl::easy::setopt($curl, CURLOPT_ERRORBUFFER, "errbuf");
+print "ok ".++$count."\n";
+
+Curl::easy::setopt($curl, CURLOPT_URL, $url);
+
+print "ok ".++$count."\n";
+
+sub passwd_callb
+{
+ my ($clientp,$prompt,$buflen)=@_;
+ print STDERR "\nperl passwd_callback has been called!\n";
+ print STDERR "clientp: $clientp, prompt: $prompt, buflen: $buflen\n";
+ print STDERR "\nEnter max $buflen characters for $prompt ";
+ my $data = <STDIN>;
+ chomp($data);
+ return (0,$data);
+}
+
+# Now do an ftp upload:
+
+
+Curl::easy::setopt($curl, Curl::easy::CURLOPT_UPLOAD, 1);
+
+
+my $read_max=1000;
+Curl::easy::setopt($curl,CURLOPT_INFILESIZE,$read_max );
+print "ok ".++$count."\n";
+
+sub read_callb
+{
+ my ($maxlen,$sv)=@_;
+ print STDERR "\nperl read_callback has been called!\n";
+ print STDERR "max data size: $maxlen - $read_max bytes needed\n";
+
+ if ($read_max > 0) {
+ my $len=int($read_max/3)+1;
+ my $data = chr(ord('A')+rand(26))x$len;
+ print STDERR "generated max/3=", int($read_max/3)+1, " characters to be uploaded - $data.\n";
+ $read_max=$read_max-length($data);
+ return $data;
+ } else {
+ return "";
+ }
+}
+
+# Use perl read callback to read data to be uploaded
+Curl::easy::setopt($curl, Curl::easy::CURLOPT_READFUNCTION, \&read_callb);
+
+# Use perl passwd callback to read password for login to ftp server
+Curl::easy::setopt($curl, Curl::easy::CURLOPT_PASSWDFUNCTION, \&passwd_callb);
+
+print "ok ".++$count."\n";
+my $bytes;
+
+# Go get it
+if (Curl::easy::perform($curl) == 0) {
+ Curl::easy::getinfo($curl, Curl::easy::CURLINFO_SIZE_UPLOAD, $bytes);
+ print STDERR "$bytes bytes transferred\n";
+} else {
+ # We can acces the error message in $errbuf here
+ print STDERR "'$errbuf'\n";
+ print "not ";
+}
+print "ok ".++$count."\n";
+
+# Cleanup
+Curl::easy::cleanup($curl);
+print "ok ".++$count."\n";
diff --git a/perl/Curl_easy/t/08ssl.t b/perl/Curl_easy/t/08ssl.t
new file mode 100644
index 000000000..0da9a556c
--- /dev/null
+++ b/perl/Curl_easy/t/08ssl.t
@@ -0,0 +1,98 @@
+# Test script for Perl extension Curl::easy.
+# Check out the file README for more info.
+
+# Before `make install' is performed this script should be runnable with
+# `make t/thisfile.t'. After `make install' it should work as `perl thisfile.t'
+
+######################### We start with some black magic to print on failure.
+
+# Change 1..1 below to 1..last_test_to_print .
+use strict;
+
+BEGIN { $| = 1; print "1..20\n"; }
+END {print "not ok 1\n" unless $::loaded;}
+use Curl::easy;
+
+$::loaded = 1;
+print "ok 1\n";
+
+######################### End of black magic.
+
+# Insert your test code below (better if it prints "ok 13"
+# (correspondingly "not ok 13") depending on the success of chunk 13
+# of the test code):
+
+my $count=1;
+
+# list of tests
+# site-url, verifypeer(0,1), verifyhost(0,2), result(0=ok, 1=fail)
+my $url_list=[
+ [ 'https://216.168.252.86/', 0, 0, 0 ], # www.awayweb.com
+ [ 'https://216.168.252.86/', 0, 2, 1 ], # www.awayweb.com
+ [ 'https://www.verisign.com/', 0, 0, 0 ],
+ [ 'https://www.verisign.com/', 0, 2, 0 ],
+ [ 'https://www.verisign.com/', 1, 2, 0 ], # these fail on openssl0.9.5 - unknown sig
+ [ 'https://www.verisign.com/', 1, 2, 0 ], # these fail on openssl0.9.5 - unknown sig
+ [ 'https://lc2.law13.hotmail.passport.com/', 0, 0, 0 ],
+ [ 'https://lc2.law13.hotmail.passport.com/', 0, 2, 0 ],
+ [ 'https://lc2.law13.hotmail.passport.com/', 1, 2, 0 ], # fail on 0.9.5
+ [ 'https://lc2.law13.hotmail.passport.com/', 1, 2, 0 ], # fail on 0.9.5
+ [ 'https://www.modssl.org/', 0, 0, 0 ],
+ [ 'https://www.modssl.org/', 0, 2, 0 ],
+ [ 'https://www.modssl.org/', 1, 0, 1 ],
+ [ 'https://www.modssl.org/', 1, 2, 1 ],
+];
+
+# Init the curl session
+my $curl = Curl::easy::init();
+if ($curl == 0) {
+ print "not ";
+}
+print "ok ".++$count."\n";
+
+
+Curl::easy::setopt($curl, CURLOPT_NOPROGRESS, 1);
+Curl::easy::setopt($curl, CURLOPT_MUTE, 0);
+#Curl::easy::setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
+Curl::easy::setopt($curl, CURLOPT_TIMEOUT, 30);
+
+my @myheaders;
+$myheaders[1] = "User-Agent: Verifying SSL functions in perl interface for libcURL";
+Curl::easy::setopt($curl, CURLOPT_HTTPHEADER, \@myheaders);
+
+open HEAD, ">head.out";
+Curl::easy::setopt($curl, CURLOPT_WRITEHEADER, *HEAD);
+print "ok ".++$count."\n";
+
+open BODY, ">body.out";
+Curl::easy::setopt($curl, CURLOPT_FILE,*BODY);
+print "ok ".++$count."\n";
+
+my $errbuf;
+Curl::easy::setopt($curl, CURLOPT_ERRORBUFFER, "errbuf");
+print "ok ".++$count."\n";
+
+Curl::easy::setopt($curl, CURLOPT_FORBID_REUSE, 1);
+
+
+print "ok ".++$count."\n";
+Curl::easy::setopt($curl, CURLOPT_CAINFO,"ca-bundle.crt");
+
+foreach my $test_list (@$url_list) {
+ my ($url,$verifypeer,$verifyhost,$result)=@{$test_list};
+ print STDERR "testing $url verify=$verifypeer at level $verifyhost expect ".($result?"fail":"pass")."\n";
+
+ Curl::easy::setopt($curl, CURLOPT_SSL_VERIFYPEER,$verifypeer); # do verify
+ Curl::easy::setopt($curl, CURLOPT_SSL_VERIFYHOST,$verifyhost); # check name
+ my $retcode;
+
+ Curl::easy::setopt($curl, CURLOPT_URL, $url);
+
+ $retcode=Curl::easy::perform($curl);
+ if ( ($retcode != 0) != $result) {
+ print STDERR "error $retcode $errbuf\n";
+ print "not ";
+ };
+ print "ok ".++$count."\n";
+
+}
diff --git a/perl/Curl_easy/t/Makefile.am b/perl/Curl_easy/t/Makefile.am
new file mode 100644
index 000000000..99466ba1d
--- /dev/null
+++ b/perl/Curl_easy/t/Makefile.am
@@ -0,0 +1,2 @@
+EXTRA_DIST = 00constants.t 01basic.t 02header-callback.t 03body-callback.t\
+04abort-test.t 05progress.t 06http-post.t 07ftp-upload.t 08ssl.t