Sample code for 30+ languages & platforms
DataFlex

Example: Http.DownloadSb method

See more HTTP Examples

Demonstrates the DownloadSb method.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoHttp
    Variant vSb
    Handle hoSb
    Integer iStatusCode
    String sTemp1

    Move False To iSuccess

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End
    Set ComKeepResponseBody Of hoHttp To True

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSb
    If (Not(IsComObjectCreated(hoSb))) Begin
        Send CreateComObject of hoSb
    End
    Get pvComObject of hoSb to vSb
    Get ComDownloadSb Of hoHttp "https://chilkatsoft.com/testData/helloWorld.txt" "utf-8" vSb To iSuccess

    Get ComLastStatus Of hoHttp To iStatusCode
    If (iSuccess = False) Begin
        If (iStatusCode = 0) Begin
            // Unable to either send the request or get the response.
            Get ComLastErrorText Of hoHttp To sTemp1
            Showln sTemp1
        End
        Else Begin
            // We got a response, but the status code was not in the 200s
            Showln "Response status code: " iStatusCode
            // Examine the response body.
            Showln "Response body:"
            Get ComLastResponseBody Of hoHttp To sTemp1
            Showln sTemp1
        End

        Showln "Download failed."

    End
    Else Begin
        Showln "Download success, response status = " iStatusCode
        Get ComGetAsString Of hoSb To sTemp1
        Showln sTemp1
    End



End_Procedure