Sample code for 30+ languages & platforms
PowerShell

Setting a HTTP Max Response Size

Demonstrates the MaxResponseSize property.

Chilkat PowerShell Downloads

PowerShell
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"

$success = $false

$http = New-Object Chilkat.Http

$maxSz = 16384
$http.MaxResponseSize = $maxSz

# Try to get something larger, such as hamlet.xml which is 279658 bytes
$xmlStr = $http.QuickGetStr("https://chilkatsoft.com/hamlet.xml")
if ($http.LastMethodSuccess -eq $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.
    $($http.LastErrorText)
    exit
}

$("OK")