Sample code for 30+ languages & platforms
Go

Transition from Http.PTextSb to Http.HttpSb

Provides instructions for replacing deprecated PTextSb method calls with HttpSb.

Chilkat Go Downloads

Go
    success := false

    http := chilkat.NewHttp()

    verb := "PUT"
    url := "https://example.com/"
    sbRequestBody := chilkat.NewStringBuilder()
    sbRequestBody.Append("This is the HTTP request body")
    charset := "utf-8"
    contentType := "text/plain"

    // ------------------------------------------------------------------------
    // The PTextSb method is deprecated:

    responseObj := http.PTextSb(verb,url,sbRequestBody,charset,contentType,false,false)
    if http.LastMethodSuccess() == false {
        fmt.Println(http.LastErrorText())
        http.DisposeHttp()
        sbRequestBody.DisposeStringBuilder()
        return
    }

    // ...
    // ...

    responseObj.DisposeHttpResponse()

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

    responseOut := chilkat.NewHttpResponse()
    success = http.HttpSb(verb,url,sbRequestBody,charset,contentType,responseOut)
    if success == false {
        fmt.Println(http.LastErrorText())
        http.DisposeHttp()
        sbRequestBody.DisposeStringBuilder()
        responseOut.DisposeHttpResponse()
        return
    }


    http.DisposeHttp()
    sbRequestBody.DisposeStringBuilder()
    responseOut.DisposeHttpResponse()