Lua
Lua
Example: Http.DownloadSb method
See more HTTP Examples
Demonstrates theDownloadSb method.
Chilkat Lua Downloads
local chilkat = require("chilkat")
local http = chilkat.Http.new()
http.keep_response_body = true
local sb = chilkat.StringBuilder.new()
local success = http:download_sb("https://chilkatsoft.com/testData/helloWorld.txt", "utf-8", sb)
local statusCode = http.last_status
if not success then
if statusCode == 0 then
-- Unable to either send the request or get the response.
print(http.last_error_text)
else
-- We got a response, but the status code was not in the 200s
print("Response status code: " .. statusCode)
-- Examine the response body.
print("Response body:")
print(http.last_response_body)
end
print("Download failed.")
else
print("Download success, response status = " .. statusCode)
print(sb:get_as_string())
end