Sample code for 30+ languages & platforms
Visual FoxPro

Clear a REST Response Body Stream Destination

See more REST Examples

Demonstrates Rest.ClearResponseBodyStream, which removes a response-stream destination previously configured with SetResponseBodyStream.

The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.

Background. Clearing the destination restores normal behavior, in which the full-request convenience methods return the response body rather than streaming it.

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loRest
LOCAL lnBTls
LOCAL lnBAutoReconnect
LOCAL loRespStream
LOCAL lnBAutoSetCharset
LOCAL lnExpectedStatus

lnSuccess = 0

loRest = CreateObject('Chilkat.Rest')
lnBTls = 1
lnBAutoReconnect = 1
lnSuccess = loRest.Connect("example.com",443,lnBTls,lnBAutoReconnect)
IF (lnSuccess = 0) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    CANCEL
ENDIF

*  The file paths are relative to the application's current working directory.  Absolute paths
*  may also be used.  Supply the paths appropriate to your own environment.

loRespStream = CreateObject('Chilkat.Stream')
loRespStream.SinkFile = "qa_output/response_body.dat"
lnBAutoSetCharset = 1
lnExpectedStatus = 200
lnSuccess = loRest.SetResponseBodyStream(lnExpectedStatus,lnBAutoSetCharset,loRespStream)
IF (lnSuccess = 0) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loRespStream
    CANCEL
ENDIF

*  Clear the response-stream destination previously configured, so subsequent full-request calls
*  return the response body normally instead of streaming it.
loRest.ClearResponseBodyStream()

? "Response body streaming cleared."

RELEASE loRest
RELEASE loRespStream