http module
HTTP requests off the frame: method, headers, body, timeout_seconds and save_to options. The reply reaches on_response as a map whose kind is response…
HTTP requests off the frame: method, headers, body, timeout_seconds and save_to options. The reply reaches on_response as a map whose kind is response, with status, headers and body, or error; save_to downloads report to on_progress 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) -> any |
— | Stop waiting on a request: its reply is dropped, a download stops writing, and the handler and any await hear kind cancelled next frame. False when it had already finished. |
request(any, any?, any?) -> any |
— | Start an HTTP request and return the id its reply carries, to await or to match inside the handler. 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 |