A simple HTTP(S) request module in pure LuaJIT. Requires libcurl binaries with SSL support, which come preinstalled on macOS and many Linux distributions. On Windows, binaries can be obtained from https://curl.haxx.se/download.html
local request = require("luajit-request")
local response = request.send("https://example.com")
print(response.code)
print(response.body)
local request = require("luajit-request")
local response = request.send("https://example.com", {
cookies = {
hello = "world"
},
auth_type = "digest",
username = "user",
password = "pass"
})
print(response.body)
print(response.set_cookies)
local request = require("luajit-request")
local response = request.send("https://example.com", {
method = "POST",
data = {
hello = "world"
}
})
print(response.code)
print(response.body)
local request = require("luajit-request")
local result, err, message = request.send("https://www.posttestserver.com/post.php", {
method = "POST",
files = {
readme = "README.md"
}
})
if (not result) then
print(err, message)
end
print(result.body)