Skip to content

Search

Documentation

http

HTTP requests off the frame: method, headers, body, timeout_seconds and save_to options. task::wait on the id answers a map whose kind is response, with…

On this page

HTTP requests off the frame: method, headers, body, timeout_seconds and save_to options. task::wait on the id answers a map whose kind is response, with status, headers and body, or error; a save_to download reports as the http_progress event with kind progress, and a body over 256 KB going out with kind upload, natively; a browser's fetch does not report one. Each kind is an EVENT_* constant.

2 functions, 5 constants. Scripts reach it as http::.

Functions

Argument kinds are the script values a call passes: node is a node handle, any a table or value of any kind, fn a callback.

function acts on what it does
cancel(int) -> bool — Stop waiting on a request: its reply is dropped, a download stops writing, and any await hears kind cancelled next frame. False when it had already finished.
request(string, http::RequestOptions?) -> int — Start an HTTP request and return the id task::wait answers its reply on. With save_to the body is written under the user directory and the reply says where in path.

Constants

name value
EVENT_CANCELLED "cancelled"
EVENT_ERROR "error"
EVENT_PROGRESS "progress"
EVENT_RESPONSE "response"
EVENT_UPLOAD "upload"

Are you sure?