Skip to content

smelt.http

Tier: Host — Available in every runtime, including headless mode.

Synchronous HTTP get/post with redirect following and header support. Errors use the (value, err_string) convention.

smelt.http.get

fun(url: string, opts: table?): table?, string?

Perform a synchronous HTTP GET against url. opts accepts headers, timeout_secs, and max_redirects. Returns ({ status, final_url, body, headers }, nil) on success or (nil, err_string) on failure.

smelt.http.post

fun(url: string, body: string?, opts: table?): table?, string?

Perform a synchronous HTTP POST against url with body bytes. opts accepts headers, timeout_secs, and max_redirects. Returns ({ status, final_url, body, headers }, nil) on success or (nil, err_string) on failure.

smelt.http.random_user_agent

fun(): string

Return a randomly selected User-Agent string from the built-in pool.