summaryrefslogtreecommitdiff
path: root/t/01basic.t
diff options
context:
space:
mode:
Diffstat (limited to 't/01basic.t')
-rw-r--r--t/01basic.t48
1 files changed, 48 insertions, 0 deletions
diff --git a/t/01basic.t b/t/01basic.t
new file mode 100644
index 0000000..5b4d175
--- /dev/null
+++ b/t/01basic.t
@@ -0,0 +1,48 @@
+#!perl
+
+use strict;
+use warnings;
+use Test::More tests => 14;
+use File::Temp qw/tempfile/;
+
+BEGIN { use_ok( 'WWW::Curl::Easy' ); }
+
+my $url = $ENV{CURL_TEST_URL} || "http://www.google.com";
+
+my $memfile = '';
+# 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");
+$curl->setopt(CURLOPT_HEADER, 1);
+
+my $head = tempfile();
+ok(! $curl->setopt(CURLOPT_WRITEHEADER, $head), "Setting CURLOPT_WRITEHEADER");
+
+my $body = tempfile();
+ok(! $curl->setopt(CURLOPT_WRITEDATA,$body), "Setting CURLOPT_WRITEDATA");
+
+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");
+
+my $retcode = $curl->perform();
+
+ok(! $retcode, "Curl return code ok");
+
+my $bytes = $curl->getinfo(CURLINFO_SIZE_DOWNLOAD);
+ok( $bytes, "getinfo returns non-zero number of bytes");
+my $realurl = $curl->getinfo(CURLINFO_EFFECTIVE_URL);
+ok( $realurl, "getinfo returns CURLINFO_EFFECTIVE_URL");
+my $httpcode = $curl->getinfo(CURLINFO_HTTP_CODE);
+ok( $httpcode, "getinfo returns CURLINFO_HTTP_CODE");
+#diag ("Bytes: $bytes");
+#diag ("realurl: $realurl");
+#diag ("httpcode: $httpcode");