Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added test_curl.p6 - a script to experiment with libcurl API

  • Loading branch information...
commit f2f22a8733effd60d3e981822a0a9f23508ea163 1 parent b146fa4
@azawawi authored
Showing with 36 additions and 0 deletions.
  1. +36 −0 test_curl.p6
View
36 test_curl.p6
@@ -0,0 +1,36 @@
+#!/usr/bin/env perl6
+
+BEGIN { @*INC.push('lib') };
+
+use Net::Curl;
+
+class Net::Curl::Easy {
+ has $.url;
+
+ method download {
+
+ my $curl = curl_easy_init;
+ if $curl {
+ curl_easy_setopt($curl, CURLOPT_URL, $.url);
+
+ # Perform the request, res will get the return code
+ my $res = curl_easy_perform($curl);
+
+ # Check for errors
+ if $res != CURLE_OK {
+ say "Error: curl_easy_perform() failed: " ~
+ curl_easy_strerror($res);
+ }
+
+ # always cleanup
+ curl_easy_cleanup($curl);
+ }
+
+ return "TODO implement .download";
+ }
+}
+
+my $curl = Net::Curl::Easy.new(url => "http://www.google.com");
+my $response = $curl.download;
+say $response;
+
Please sign in to comment.
Something went wrong with that request. Please try again.