DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoRest
Boolean iBTls
Boolean iBAutoReconnect
Variant vRespStream
Handle hoRespStream
Boolean iBAutoSetCharset
Integer iExpectedStatus
String sTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatRest)) To hoRest
If (Not(IsComObjectCreated(hoRest))) Begin
Send CreateComObject of hoRest
End
Move True To iBTls
Move True To iBAutoReconnect
Get ComConnect Of hoRest "example.com" 443 iBTls iBAutoReconnect To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoRest To sTemp1
Showln sTemp1
Procedure_Return
End
// 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.
Get Create (RefClass(cComChilkatStream)) To hoRespStream
If (Not(IsComObjectCreated(hoRespStream))) Begin
Send CreateComObject of hoRespStream
End
Set ComSinkFile Of hoRespStream To "qa_output/response_body.dat"
Move True To iBAutoSetCharset
Move 200 To iExpectedStatus
Get pvComObject of hoRespStream to vRespStream
Get ComSetResponseBodyStream Of hoRest iExpectedStatus iBAutoSetCharset vRespStream To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoRest To sTemp1
Showln sTemp1
Procedure_Return
End
// Clear the response-stream destination previously configured, so subsequent full-request calls
// return the response body normally instead of streaming it.
Send ComClearResponseBodyStream To hoRest
Showln "Response body streaming cleared."
End_Procedure