Sample code for 30+ languages & platforms
Lua

Inspect HTTP Request Header

Demonstrates the LastHeader property.

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

local http = chilkat.Http.new()

local url = "https://chilkatsoft.com/echo_request_body.asp"
local json = "{\"greeting\":\"Hello World\"}"

-- Send a POST with the JSON in the HTTP request body.
local resp = chilkat.HttpResponse.new()
local success = http:http_str("POST", url, json, "utf-8", "application/json", resp)
if not success then
    print(http.last_error_text)
    return
end

-- Examine the HTTP request header we just sent.
print(http.last_header)

-- Output:

-- POST /echo_request_body.asp HTTP/1.1
-- Host: chilkatsoft.com
-- Accept: */*
-- Accept-Encoding: gzip
-- Content-Type: application/json
-- Content-Length: 26