Sample code for 30+ languages & platforms
Swift

Demonstrate HttpRequest.RemoveAllParams

Demonstrates the effect of calling HttpRequest.RemoveAllParams.

Chilkat Swift Downloads

Swift

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&paramB=BBB&paramC=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&paramE=EEE&paramF=FFF

}