(Go) Example: Http.DownloadSb method
Demonstrates the DownloadSb method.
success := false
http := Http_Ref.html">chilkat.NewHttp()
http.SetKeepResponseBody(true)
sb := StringBuilder_Ref.html">chilkat.NewStringBuilder()
success = http.DownloadSb("https://chilkatsoft.com/testData/helloWorld.txt","utf-8",sb)
statusCode := http.LastStatus()
if success == false {
if statusCode == 0 {
// Unable to either send the request or get the response.
fmt.Println(http.LastErrorText())
} else {
// We got a response, but the status code was not in the 200s
fmt.Println("Response status code: ", statusCode)
// Examine the response body.
fmt.Println("Response body:")
fmt.Println(http.LastResponseBody())
}
fmt.Println("Download failed.")
} else {
fmt.Println("Download success, response status = ", statusCode)
fmt.Println(*sb.GetAsString())
}
http.DisposeHttp()
sb.DisposeStringBuilder()
|