Xbase++
Xbase++
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 Xbase++ Downloads
LOCAL nSuccess
LOCAL oRest
LOCAL nBTls
LOCAL nBAutoReconnect
LOCAL oRespStream
LOCAL nBAutoSetCharset
LOCAL nExpectedStatus
nSuccess := 0
oRest := CreateObject("Chilkat.Rest")
nBTls := 1
nBAutoReconnect := 1
nSuccess := oRest:Connect("example.com", 443, nBTls, nBAutoReconnect)
IF (nSuccess == 0)
? oRest:LastErrorText
oRest:destroy()
RETURN
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.
oRespStream := CreateObject("Chilkat.Stream")
oRespStream:SinkFile := "qa_output/response_body.dat"
nBAutoSetCharset := 1
nExpectedStatus := 200
nSuccess := oRest:SetResponseBodyStream(nExpectedStatus, nBAutoSetCharset, oRespStream)
IF (nSuccess == 0)
? oRest:LastErrorText
oRest:destroy()
oRespStream:destroy()
RETURN
ENDIF
// Clear the response-stream destination previously configured, so subsequent full-request calls
// return the response body normally instead of streaming it.
oRest:ClearResponseBodyStream()
? "Response body streaming cleared."
oRest:destroy()
oRespStream:destroy()