Sample code for 30+ languages & platforms
Swift

Send HTTPS Get Without Waiting for the Response

See more REST Examples

This example demonstrates sending an HTTP GET request without waiting for the response.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    let rest = CkoRest()!

    // Connect to the server using TLS
    var bAutoReconnect: Bool = false
    success = rest.connect(hostname: "example.com", port: 443, tls: true, autoReconnect: bAutoReconnect)
    if success == false {
        print("\(rest.lastErrorText!)")
        return
    }

    // Send a GET request to https://example.com/some/path 
    success = rest.sendReqNoBody(httpVerb: "GET", uriPath: "/some/path")
    if success == false {
        print("\(rest.lastErrorText!)")
        return
    }

    // OK, the request was sent.
    // Close the connection.
    var maxWaitMs: Int = 50
    rest.disconnect(maxWaitMs: maxWaitMs)

    print("GET Request Sent.")

}