Sample code for 30+ languages & platforms
Perl

Example: Http.DownloadSb method

See more HTTP Examples

Demonstrates the DownloadSb method.

Chilkat Perl Downloads

Perl
use chilkat();

$success = 0;

$http = chilkat::CkHttp->new();
$http->put_KeepResponseBody(1);

$sb = chilkat::CkStringBuilder->new();
$success = $http->DownloadSb("https://chilkatsoft.com/testData/helloWorld.txt","utf-8",$sb);

$statusCode = $http->get_LastStatus();
if ($success == 0) {
    if ($statusCode == 0) {
        # Unable to either send the request or get the response.
        print $http->lastErrorText() . "\r\n";
    }
    else {
        # We got a response, but the status code was not in the 200s
        print "Response status code: " . $statusCode . "\r\n";
        # Examine the response body.
        print "Response body:" . "\r\n";
        print $http->lastResponseBody() . "\r\n";
    }

    print "Download failed." . "\r\n";

}
else {
    print "Download success, response status = " . $statusCode . "\r\n";
    print $sb->getAsString() . "\r\n";
}