Perl
Chilkat2 Perl
Example: Http.QuickGetStr method
Demonstrates theQuickGetStr method.
Chilkat Perl Downloads
use strict;
use warnings;
use Chilkat2;
my $http = Chilkat2::Http->new;
# Keep the response body if there's an error.
$http->KeepResponseBody(1);
# Send the HTTP GET and return the content in a string.
my $str = $http->QuickGetStr('https://www.chilkatsoft.com/helloWorld.json');
if (!$http->LastMethodSuccess) {
if ($http->LastStatus == 0) {
# Communications error. We did not get a response.
print $http->LastErrorText, "\n";
} else {
print 'Response status code: ', $http->LastStatus, "\n";
print "Response body error text:\n";
print $http->LastResponseBody, "\n";
}
exit;
}
print $str, "\n";
print "Success\n";