Swift
Swift
Demonstrate HttpRequest.RemoveAllParams
Demonstrates the effect of calling HttpRequest.RemoveAllParams.Chilkat Swift Downloads
func chilkatTest() {
let req = CkoHttpRequest()!
req.httpVerb = "POST"
req.path = "/test123"
req.contentType = "application/x-www-form-urlencoded"
req.addParam(name: "paramA", value: "AAA")
req.addParam(name: "paramB", value: "BBB")
req.addParam(name: "paramC", value: "CCC")
print("\(req.generateRequestText()!)")
print("---------------")
// Generates:
// POST /test123 HTTP/1.1
// Content-Type: application/x-www-form-urlencoded
// Host: domain
// Content-Length: 32
//
// paramA=AAA¶mB=BBB¶mC=CCC
//
// If we call RemoveAllParams, and then add some additional params,
// then the original params are gone, and only the new params exist.
req.removeAllParams()
req.addParam(name: "paramD", value: "DDD")
req.addParam(name: "paramE", value: "EEE")
req.addParam(name: "paramF", value: "FFF")
print("\(req.generateRequestText()!)")
print("---------------")
// Generates:
// POST /test123 HTTP/1.1
// Content-Type: application/x-www-form-urlencoded
// Host: domain
// Content-Length: 32
//
// paramD=DDD¶mE=EEE¶mF=FFF
}