Sample code for 30+ languages & platforms
JavaScript

Setting a HTTP Max Response Size

Demonstrates the MaxResponseSize property.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var success = false;

var http = new CkHttp();

var maxSz = 16384;
http.MaxResponseSize = maxSz;

// Try to get something larger, such as hamlet.xml which is 279658 bytes
var xmlStr = http.QuickGetStr("https://chilkatsoft.com/hamlet.xml");
if (http.LastMethodSuccess == false) {
    // 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.
    console.log(http.LastErrorText);
    return;
}

console.log("OK");