Lua
Lua
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 Lua Downloads
local chilkat = require("chilkat")
local rest = chilkat.Rest.new()
local bTls = true
local bAutoReconnect = true
local success = rest:connect("example.com", 443, bTls, bAutoReconnect)
if not success then
print(rest.last_error_text)
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.
local respStream = chilkat.Stream.new()
respStream.sink_file = "qa_output/response_body.dat"
local bAutoSetCharset = true
local expectedStatus = 200
success = rest:set_response_body_stream(expectedStatus, bAutoSetCharset, respStream)
if not success then
print(rest.last_error_text)
return
end
-- Clear the response-stream destination previously configured, so subsequent full-request calls
-- return the response body normally instead of streaming it.
rest:clear_response_body_stream()
print("Response body streaming cleared.")