Skip to content

HttpGetToFile - cHttpClient

Include: Use System\Http.pkg

Sends a GET request and writes the response body to a file.

Type: Function

Return data type: HttpStatus, which is an alias for UShort

Parameters

Parameter Type Description
sPath String Relative path or absolute URL.
sFile String File path to create or truncate for the response body.

Syntax

Function HttpGetToFile String sPath String sFile Returns HttpStatus

Call

Get HttpGetToFile of hoObj "/get" "httpbin.body" to eStatus

Description

Sends GET and writes the response body to sFile. HttpResponseBody is empty after file download. The file is created/truncated and removed on send failure.

Example

Handle hoObj
HttpStatus eStatus
String sBody
UBigInt uiContentLength

Get Create (RefClass(cHttpClient)) to hoObj
Set psEndpoint of hoObj to C_HTTP_ENDPOINT
Set HttpHeader of hoObj to "Demo" "Value"
Get HttpGetToFile of hoObj "/get" "httpbin.body" to eStatus
Get HttpResponseBody of hoObj to sBody
Get HttpResponseContentLength of hoObj to uiContentLength
Send Destroy of hoObj