This is a readonly property that returns a
table
, but you can set/get its individual fields or iterate over.Http.headers readonly property
The Http.headers property returns a table that contains the headers of the requests to be sent to the server (where keys and values are strings
representing header names and values respectively).
Example
local net = require "net"
local client = net.Http("https://httpbin.org")
-- add header "Content-Type" with the value "text/plain" for next requests
client.headers["Content-Type"] = "text/plain"
-- the data to be posted (in text/plain format)
local data = [[Hello World !]]
-- make a POST request, and after its terminated, call the provided function, to process the response
client:post("/post", data).after = function (self, response)
if not response then
error(net.error)
end
print(response.content)
end
waitall()