Skip to main content

http_request_impl

Function http_request_impl 

Source
pub fn http_request_impl(
    lua: &Lua,
    args: (String, String, Option<Table>),
) -> Result<Table>
Expand description

Executes an HTTP request using ureq. Called from capability-gated context.

§Arguments (from Lua)

  • method - HTTP method: “GET”, “POST”, “PUT”, “DELETE”, “PATCH”, “HEAD”
  • url - Request URL (must be http:// or https://)
  • opts - Optional table:
    • headers - Table of {name = value} pairs
    • body - Request body string
    • timeout - Timeout in seconds (default: 30)

§Returns (Lua table)

  • ok - boolean, true if HTTP response received (even 4xx/5xx)
  • status - HTTP status code (number)
  • headers - Response headers as {name = value} table
  • body - Response body as string
  • error - Error message (only when ok=false)
  • error_kind - Error classification: “timeout”, “dns”, “connection_refused”, “tls”, “too_large”, “invalid_url”, “network”, “unknown”