Simple HTTPS for LuaJIT!
Clone or download
Latest commit ef731ad Jun 27, 2018
Permalink
Failed to load latest commit information.
luajit-request Fix request being sent with GET instead of POST if data is empty, closes Jun 16, 2018
LICENSE.md
README.md Update links to binaries and clean up README Jul 19, 2017
changelog.md Mark release 2.4.0 Mar 6, 2016

README.md

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)