PureBasic
PureBasic
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 PureBasic Downloads
IncludeFile "CkRest.pb"
IncludeFile "CkStream.pb"
Procedure ChilkatExample()
success.i = 0
rest.i = CkRest::ckCreate()
If rest.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
bTls.i = 1
bAutoReconnect.i = 1
success = CkRest::ckConnect(rest,"example.com",443,bTls,bAutoReconnect)
If success = 0
Debug CkRest::ckLastErrorText(rest)
CkRest::ckDispose(rest)
ProcedureReturn
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.
respStream.i = CkStream::ckCreate()
If respStream.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkStream::setCkSinkFile(respStream, "qa_output/response_body.dat")
bAutoSetCharset.i = 1
expectedStatus.i = 200
success = CkRest::ckSetResponseBodyStream(rest,expectedStatus,bAutoSetCharset,respStream)
If success = 0
Debug CkRest::ckLastErrorText(rest)
CkRest::ckDispose(rest)
CkStream::ckDispose(respStream)
ProcedureReturn
EndIf
; Clear the response-stream destination previously configured, so subsequent full-request calls
; return the response body normally instead of streaming it.
CkRest::ckClearResponseBodyStream(rest)
Debug "Response body streaming cleared."
CkRest::ckDispose(rest)
CkStream::ckDispose(respStream)
ProcedureReturn
EndProcedure