Sample code for 30+ languages & platforms
B4X

Example: Http.DownloadSb method

See more HTTP Examples

Demonstrates the DownloadSb method.

Chilkat B4X Downloads

B4X
Dim success As Boolean = False

Dim http As ChilkatHttp
http.Initialize("http")
http.KeepResponseBody = True

Dim sb As ChilkatStringBuilder
sb.Initialize
success = http.DownloadSb("https://chilkatsoft.com/testData/helloWorld.txt", "utf-8", sb)

Dim statusCode As Int = http.LastStatus
If success = False Then
    If statusCode = 0 Then
        '  Unable to either send the request or get the response.
        Log(http.LastErrorText)
    Else
        '  We got a response, but the status code was not in the 200s
        Log("Response status code: " & statusCode)
        '  Examine the response body.
        Log("Response body:")
        Log(http.LastResponseBody)
    End If

    Log("Download failed.")

Else
    Log("Download success, response status = " & statusCode)
    Log(sb.GetAsString)
End If