HTTP REQUEST

HttpGet

Performs an HTTP GET request and returns the body.

Syntax

local status, body = ONYX.HttpGet(url)

Parameters

  • url (string) — Absolute URL.

Return(s)

status (number) — HTTP status; body (string) — response body; on error nil and a message.

Behavior

  • Blocking call that runs on the calling thread.
  • Follows redirects and accepts gzip/deflate responses.
  • TLS verification is enabled.
  • No custom headers or timeout in this variant.
  • The body may be binary; use #body for its length.

Example(s)

local status, body = ONYX.HttpGet("https://httpbin.org/get")
if not status then print("failed", body) else print(status, #body) end