Sample code for 30+ languages & platforms
Swift

Setting a HTTP Max Response Size

Demonstrates the MaxResponseSize property.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    let http = CkoHttp()!

    var maxSz: UInt32 = 16384
    http.maxResponseSize = maxSz

    // Try to get something larger, such as hamlet.xml which is 279658 bytes
    var xmlStr: String? = http.quickGetStr(url: "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.
        print("\(http.lastErrorText!)")
        return
    }

    print("OK")

}