Expand description
A WHATWG-ish fetch + Headers + Response, so npm packages that
expect fetch work. It is a thin surface over the SAME
ferridriver::http_client core the Playwright-style request
binding uses — one HTTP stack, one place the net policy applies. The
ergonomic request API stays; this just adds the standard entry
point.
Web-standard names: Headers, Request, Response are the WHATWG
classes (the Playwright page-network Request/Response are no
longer globals — they were never globals in Playwright either, only
return values). Headers is spec (lowercase + RFC7230 validate,
value normalize, , combine, separate set-cookie +
getSetCookie, sorted real iterators, forEach). Response /
Request are constructible with the spec accessors
(status/ok/redirected/type/bodyUsed/headers/…),
single-use bodies (text/json/arrayBuffer), clone(), and
static Response.json/error/redirect. fetch(url, { signal })
is wired to AbortController/AbortSignal (see super::abort):
an already-aborted signal rejects before I/O and an in-flight abort
drops the request future. Response.body is a ReadableStream
that pulls chunks live off the socket (the body is NOT buffered;
text()/json()/arrayBuffer() drain it on demand) — see
super::streams. Blob and FormData (see super::blob /
super::form_data) are accepted as bodies — a Blob sends its
bytes + type, a FormData is serialized as multipart/form-data.
Still a subset: clone() of a not-yet-read streamed Response
throws (no stream tee); a signal on a Request
instance is not yet forwarded (pass it via init.signal);
init.redirect maps onto the per-request redirect
cap (manual/error -> don’t follow; a spec-exact opaque-redirect /
rejection is not distinguishable through reqwest’s per-request
policy).
Net policy: fetch is a facade over the SAME core a net-restricted
tool’s request wraps, so the allow.net allow-list must bind here
too — otherwise a tool restricted to host X could reach anywhere via
the global fetch. The per-tool allow-list lives in NetPolicyUd
(VM userdata); plugins::dispatch_tool brackets each handler poll so
the policy in effect is whichever tool’s continuation is running, and
fetch snapshots it synchronously at call time (before any I/O).
Structs§
- Fetch
Request Js - WHATWG
Request(spec subset). Constructible (new Request(input, init?)whereinputis a URL string or anotherRequest), withurl/method/headers/redirect/credentials/bodyUsedaccessors andtext/json/arrayBuffer/clone.signalis accepted and stored but not yet wired (AbortController follow-up);fetchreadsurl/method/headers/body/redirectoff aRequestargument. - Fetch
Response Js - WHATWG
Response(spec subset). Constructible (new Response(body?, init?)), withstatus/ok/statusText/url/redirected/type/bodyUsed/headersaccessors,text/json/arrayBufferbody readers (single-use: a second read throws, per spec),clone()(throws once the body is used), and staticResponse.json,Response.error,Response.redirect. This is the globalResponse(the Playwright page-networkResponseis no longer a global — it is only ever a return value, matching Playwright itself). - Headers
Js - WHATWG
Headers(spec subset, no external deps): names are lowercased and RFC7230-validated, values are HTTP-whitespace normalized and validated,appendcombines same-name values with,(;forcookie) whileset-cookieis kept as separate entries,getSetCookie()returns them all, and iteration is sorted by name.keys/values/entries/[Symbol.iterator]return real iterator objects.
Functions§
- install
- Install
globalThis.fetch, bound tocx(the session’s HTTP context — same one therequestbinding wraps). Net policy that applies torequestapplies here because it is the same core.