Sample code for 30+ languages & platforms
PowerBuilder

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 PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Rest
integer li_BTls
integer li_BAutoReconnect
oleobject loo_RespStream
integer li_BAutoSetCharset
integer li_ExpectedStatus

li_Success = 0

loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat.Rest")
if li_rc < 0 then
    destroy loo_Rest
    MessageBox("Error","Connecting to COM object failed")
    return
end if
li_BTls = 1
li_BAutoReconnect = 1
li_Success = loo_Rest.Connect("example.com",443,li_BTls,li_BAutoReconnect)
if li_Success = 0 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    return
end if

//  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.

loo_RespStream = create oleobject
li_rc = loo_RespStream.ConnectToNewObject("Chilkat.Stream")

loo_RespStream.SinkFile = "qa_output/response_body.dat"
li_BAutoSetCharset = 1
li_ExpectedStatus = 200
li_Success = loo_Rest.SetResponseBodyStream(li_ExpectedStatus,li_BAutoSetCharset,loo_RespStream)
if li_Success = 0 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_RespStream
    return
end if

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

Write-Debug "Response body streaming cleared."


destroy loo_Rest
destroy loo_RespStream