diff options
author | Daniel Stenberg <daniel@haxx.se> | 2001-10-01 07:44:12 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2001-10-01 07:44:12 +0000 |
commit | 91275548528859f882c87c2131d3c96a0abd5938 (patch) | |
tree | 791ad8ca8040d3555267bdbff267148362825bd9 /perl/Curl_easy | |
parent | 9ff28a823702781f7e90cd44f31032a453827e7a (diff) |
moved to the perl module
Diffstat (limited to 'perl/Curl_easy')
-rw-r--r-- | perl/Curl_easy/examples/basicfirst.pl | 48 | ||||
-rw-r--r-- | perl/Curl_easy/t/00constants.t | 38 | ||||
-rw-r--r-- | perl/Curl_easy/t/01basic.t | 93 | ||||
-rw-r--r-- | perl/Curl_easy/t/02header-callback.t | 89 | ||||
-rw-r--r-- | perl/Curl_easy/t/03body-callback.t | 105 | ||||
-rw-r--r-- | perl/Curl_easy/t/04abort-test.t | 87 | ||||
-rw-r--r-- | perl/Curl_easy/t/05progress.t | 99 | ||||
-rw-r--r-- | perl/Curl_easy/t/06http-post.t | 99 | ||||
-rw-r--r-- | perl/Curl_easy/t/07ftp-upload.t | 129 | ||||
-rw-r--r-- | perl/Curl_easy/t/08ssl.t | 98 | ||||
-rw-r--r-- | perl/Curl_easy/t/Makefile.am | 2 |
11 files changed, 0 insertions, 887 deletions
diff --git a/perl/Curl_easy/examples/basicfirst.pl b/perl/Curl_easy/examples/basicfirst.pl deleted file mode 100644 index a04deb515..000000000 --- a/perl/Curl_easy/examples/basicfirst.pl +++ /dev/null @@ -1,48 +0,0 @@ -# Test script for Perl extension Curl::easy. -# Check out the file README for more info. - -use strict; -use Curl::easy; - -my $url = "http://curl.haxx.se/dev/"; - -print "Testing curl version ",&Curl::easy::version(),"\n"; - -# Init the curl session -my $curl= Curl::easy::init(); -if(!$curl) { - die "curl init failed!\n"; -} - -# Follow location headers - Curl::easy::setopt($curl, CURLOPT_FOLLOWLOCATION, 1); - -# Add some additional headers to the http-request: -my @myheaders; -$myheaders[0] = "I-am-a-silly-programmer: yes indeed you are"; -$myheaders[1] = "User-Agent: Perl interface for libcURL"; - Curl::easy::setopt($curl, Curl::easy::CURLOPT_HTTPHEADER, \@myheaders); - -my $errbuf; -Curl::easy::setopt($curl, CURLOPT_ERRORBUFFER, "errbuf"); - -Curl::easy::setopt($curl, CURLOPT_URL, $url); - -sub body_callback { - my ($chunk,$handle)=@_; - push @$handle, $chunk; - return length($chunk); # OK -} - Curl::easy::setopt($curl, CURLOPT_WRITEFUNCTION, \&body_callback); - -my @body; - Curl::easy::setopt($curl, CURLOPT_FILE, \@body); - -if (Curl::easy::perform($curl) != 0) { - print "Failed :$errbuf\n"; -}; - -# Cleanup - Curl::easy::cleanup($curl); - -print @body; diff --git a/perl/Curl_easy/t/00constants.t b/perl/Curl_easy/t/00constants.t deleted file mode 100644 index 2ef15453e..000000000 --- a/perl/Curl_easy/t/00constants.t +++ /dev/null @@ -1,38 +0,0 @@ - -# 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 deleted file mode 100644 index 79a6e8a24..000000000 --- a/perl/Curl_easy/t/01basic.t +++ /dev/null @@ -1,93 +0,0 @@ -# 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 deleted file mode 100644 index 94a745c39..000000000 --- a/perl/Curl_easy/t/02header-callback.t +++ /dev/null @@ -1,89 +0,0 @@ -# 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 deleted file mode 100644 index 94786f507..000000000 --- a/perl/Curl_easy/t/03body-callback.t +++ /dev/null @@ -1,105 +0,0 @@ -# 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 deleted file mode 100644 index c3d71bb02..000000000 --- a/perl/Curl_easy/t/04abort-test.t +++ /dev/null @@ -1,87 +0,0 @@ -# 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 deleted file mode 100644 index ffcdb8036..000000000 --- a/perl/Curl_easy/t/05progress.t +++ /dev/null @@ -1,99 +0,0 @@ -# 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 deleted file mode 100644 index c38cab98d..000000000 --- a/perl/Curl_easy/t/06http-post.t +++ /dev/null @@ -1,99 +0,0 @@ -# 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 deleted file mode 100644 index c23a180d2..000000000 --- a/perl/Curl_easy/t/07ftp-upload.t +++ /dev/null @@ -1,129 +0,0 @@ -# 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 deleted file mode 100644 index 0da9a556c..000000000 --- a/perl/Curl_easy/t/08ssl.t +++ /dev/null @@ -1,98 +0,0 @@ -# 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 deleted file mode 100644 index 99466ba1d..000000000 --- a/perl/Curl_easy/t/Makefile.am +++ /dev/null @@ -1,2 +0,0 @@ -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 |