Sample code for 30+ languages & platforms
Swift

Transition from Http.PBinaryBd to Http.HttpBd

Provides instructions for replacing deprecated PBinaryBd method calls with HttpBd.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    let http = CkoHttp()!

    var verb: String? = "POST"
    var url: String? = "https://example.com/"
    let bdRequestBody = CkoBinData()!
    var contentType: String? = "application/octet-stream"

    // ------------------------------------------------------------------------
    // The PBinaryBd method is deprecated:

    var responseObj: CkoHttpResponse? = http.pBinaryBd(verb: verb, url: url, data: bdRequestBody, contentType: contentType, md5: false, gzip: false)
    if http.lastMethodSuccess == false {
        print("\(http.lastErrorText!)")
        return
    }

    // ...
    // ...

    responseObj = nil

    // ------------------------------------------------------------------------
    // Do the equivalent using HttpBd.
    // Your application creates a new, empty HttpResponse object which is passed 
    // in the last argument and filled upon success.

    let responseOut = CkoHttpResponse()!
    success = http.httpBd(verb: verb, url: url, bd: bdRequestBody, contentType: contentType, response: responseOut)
    if success == false {
        print("\(http.lastErrorText!)")
        return
    }


}