Skip to content

Latest commit

 

History

History
70 lines (54 loc) · 1.51 KB

README.md

File metadata and controls

70 lines (54 loc) · 1.51 KB

LuaJIT-Request

shield_license shield_release_version

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

Usage

Simple GET

local request = require("luajit-request")
local response = request.send("https://example.com")

print(response.code)
print(response.body)

Digest Authentication and Cookies

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)

Forms

local request = require("luajit-request")

local response = request.send("https://example.com", {
	method = "POST",
	data = {
		hello = "world"
	}
})

print(response.code)
print(response.body)

Stream file (2.3+)

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)