Docs / HTTP

HTTP

Outbound HTTP client. Everything yields.

Library#15 of 23 Functions3
httpget(url: string, followRedirects: boolean?) → string yields
GET request. Returns the response body.
lua
local body = httpget("https://api.github.com")
print(body:sub(1, 60))
httppost(url: string, body: string, contentType: string?) → string yields
POST request. Returns the response body.
lua
local resp = httppost(
    "https://httpbin.org/post",
    '{"hello":"world"}',
    "application/json"
)
print(resp)
request(options: table) → table yields
Full request. Options: Url, Method, Headers, Body, Cookies. Response: {Success, StatusCode, StatusMessage, Headers, Body}.
aliaseshttp_request, http.request
lua
local r = request({
    Url     = "https://httpbin.org/headers",
    Method  = "GET",
    Headers = { ["User-Agent"] = "Velocity/1.0" },
})
print(r.StatusCode, r.Body)