Sample code for 30+ languages & platforms
Perl

Setting a HTTP Max Response Size

Demonstrates the MaxResponseSize property.

Chilkat Perl Downloads

Chilkat2 Perl
use strict;
use warnings;
use Chilkat2;

my $success = 0;

my $http = Chilkat2::Http->new;

my $maxSz = 16384;
$http->MaxResponseSize($maxSz);

# Try to get something larger, such as hamlet.xml which is 279658 bytes
my $xmlStr = $http->QuickGetStr('https://chilkatsoft.com/hamlet.xml');
if (!$http->LastMethodSuccess) {
    # If the LastErrorText contains the string "MaxResponseSize",
    # then the HTTP request failed because the response body would've been larger than the max allowed response size.
    print $http->LastErrorText, "\n";
    exit;
}

print "OK\n";