Swift
Swift
Transition from Http.PostBinary to Http.HttpBinary
Provides instructions for replacing deprecated PostBinary method calls with HttpBinary.Chilkat Swift Downloads
func chilkatTest() {
var success: Bool = false
let http = CkoHttp()!
var verb: String? = "POST"
var url: String? = "https://example.com/"
var byteData: NSData
var contentType: String? = "application/octet-stream"
// ------------------------------------------------------------------------
// The PostBinary method is deprecated:
var responseBody: String? = http.postBinary(url: url, byteData: byteData, contentType: contentType, md5: false, gzip: false)
if http.lastMethodSuccess == false {
print("\(http.lastErrorText!)")
return
}
// ...
// ...
// ------------------------------------------------------------------------
// Do the equivalent using HttpBinary.
let responseOut = CkoHttpResponse()!
success = http.httpBinary(verb: verb, url: url, byteData: byteData, contentType: contentType, response: responseOut)
if success == false {
print("\(http.lastErrorText!)")
return
}
responseBody = responseOut.bodyStr
}