Sample code for 30+ languages & platforms
Go

Transition from Http.SynchronousRequest to Http.HttpSReq

Provides instructions for replacing deprecated SynchronousRequest method calls with HttpSReq.

Chilkat Go Downloads

Go
    success := false

    http := chilkat.NewHttp()

    domain := "example.com"
    port := 443
    tls := true

    req := chilkat.NewHttpRequest()
    req.SetHttpVerb("POST")
    req.SetPath("/some/path")
    req.SetContentType("application/x-www-form-urlencoded")
    req.AddParam("firstName","Matt")
    req.AddParam("lastName","Smith")

    // ------------------------------------------------------------------------
    // The SynchronousRequest method is deprecated:

    responseObj := http.SynchronousRequest(domain,port,tls,req)
    if http.LastMethodSuccess() == false {
        fmt.Println(http.LastErrorText())
        http.DisposeHttp()
        req.DisposeHttpRequest()
        return
    }

    // ...
    // ...

    responseObj.DisposeHttpResponse()

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

    responseOut := chilkat.NewHttpResponse()
    success = http.HttpSReq(domain,port,tls,req,responseOut)
    if success == false {
        fmt.Println(http.LastErrorText())
        http.DisposeHttp()
        req.DisposeHttpRequest()
        responseOut.DisposeHttpResponse()
        return
    }


    http.DisposeHttp()
    req.DisposeHttpRequest()
    responseOut.DisposeHttpResponse()