Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added examples/getinfo.p6 to read the content-type
- Loading branch information
Showing
2 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,28 @@ | |||
#!/usr/bin/env perl6 | |||
use v6; | |||
|
|||
BEGIN { @*INC.push('lib') }; | |||
|
|||
use Net::Curl; | |||
use NativeCall; | |||
|
|||
my $curl = curl_easy_init; | |||
die "Failed to curl_easy_init" unless $curl; | |||
|
|||
curl_easy_setopt($curl, CURLOPT_URL, 'http://www.example.com/'); | |||
|
|||
my $res = curl_easy_perform($curl); | |||
|
|||
if CURLE_OK == $res { | |||
|
|||
# ask for the content-type | |||
my $ct = CArray[int].new; | |||
$res = curl_easy_getinfo($curl, CURLINFO_CONTENT_TYPE, $ct); | |||
|
|||
if (CURLE_OK == $res) && $ct { | |||
printf("We received Content-Type: %s\n", $ct); | |||
} | |||
|
|||
# always cleanup | |||
curl_easy_cleanup($curl); | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters