Expand description
gasm:fetch for the native runner: HTTP(S) requests made for the guest (design/fetch.md).
Each request runs on a background thread (ureq, rustls with ring, the OS
certificate store or SSL_CERT_FILE); the guest polls a handle, so nothing
blocks a frame. Redirects are followed here, not by ureq, so every hop is
checked against the host list. The body arrives in chunks through a bounded
channel: a guest that stops reading pauses the download.
Headless runs can record responses (--fetch-record DIR) and replay them
(--fetch-replay DIR): a replayed request completes at the start of the
next frame, on every runner, so hashes compare. The record format and key
are shared with runners/web/lib/fetch.js.
Structs§
Enums§
- Fetch
Mode - Where responses come from.
Constants§
- DONE
- FAILED
- FORBIDDEN_
HEADERS - Request headers browsers don’t let pages set (the Fetch standard’s forbidden request headers, plus user-agent): a request with one fails on every runner, so a game can’t come to depend on it. Same list in runners/web/lib/fetch.js.
- FORBIDDEN_
PREFIXES - HEADERS
- HIDDEN_
RESPONSE_ HEADERS - Response headers no runner reports: connection-level ones (browsers’ fetch() hides them or they differ by HTTP version) and cookies (fetch() never exposes them). Same list in runners/web/lib/fetch.js.
- MAX_
BODY - Largest response body; a larger one fails the request.
- MAX_
REQUESTS - MAX_
REQUEST_ BODY - METHODS
- PENDING
Functions§
- header_
lines - Response headers as the guest sees them, the way fetch()’s Headers lists them:
name: valuelines sorted by (lowercase) name, repeated names joined with “, “. The body the guest reads is always decoded (gzip natively; browsers decode everything), socontent-encodingis left out, andcontent-lengthtoo when it counted encoded bytes. - parse_
desc - Parse and check a request description; Err says why it’s refused.
- record_
key - FNV-1a 64 of method, URL and body: the name of a recorded response.
- resolve_
url locationrelative tobase(absolute, origin-relative, or path-relative).- user_
agent gasm-run/<version>, after the game’s own identity if it has one (--app-id "mygame/1.2 (+https://mygame.example)").- valid_
app_ id - Whether
idcan go into a User-Agent header: printable ASCII, 1 to 256 characters.