CODE
----------------------------------------------------------------------------------------------------------
-- Name: httpsample.lua
-- Author: Intellipool AB
-- Version: 1.0
-- Date: 2006-03-04
-- Description: Demonstrates the HTTP client class
----------------------------------------------------------------------------------------------------------
http = TLuaHTTPClient:new()
-- Connect using the default parameters
iRet = http:Connect()
if iRet ~= 0 then
    -- Make a GET request to default document
    iRet = http:Get("/")
    -- Print returned code from HTTP server
    print("Code:"..iRet)
    -- Extract content length
    iRet = http:GetHeaderContentLength()
    print("Content length:"..iRet)
    -- Print content
    string,iRet = http:GetContent(iRet)
    print(string)
    -- Print raw headers
    string = http:GetHeadersRaw()
    print("headers:\n"..string)
    -- Print cookies
    string = http:GetHeaderCookies()
    print("Cookies:\n"..string)

    -- Extract and print cookies one by one
    iNumber = http:GetHeaderCookieCount()
    for count = 0, iNumber-1 do
        string = http:GetHeaderCookie(count)
        print("Coookie #"..count.." "..string.."\n")
    end
    
    -- Extract location header
    string = http:GetHeaderLocation();
    print("location:\n"..string)
    SetExitStatus("Test ok",true)
else
    print("Connect failed")
    SetExitStatus("Test failed",false)
end