demo · v132
Request.bytes() — the upload side
Most fetch demos cover the response side. Request.bytes() is just as new: it lets a worker / service-worker round-trip a body as a single Uint8Array, then re-attach it to an upstream fetch. Useful for payload sniffing, content negotiation rewriting, and signing.
checking Request.prototype.bytes…
request.bytes() length
—
bytes returned by the single .bytes() call
round-trip time
—
ms construct + read
hex preview
—
the code
const req = new Request("/api", { method: "POST", body: payload });
const bytes = await req.bytes(); // Uint8Array, no ArrayBuffer detour
// sign or rewrite, then re-fetch
fetch(new Request("/api", { method: "POST", body: bytes }));
see also
- Request/Response.bytes() — feature index
- Response.bytes() timing
- Spec
- ChromeStatus entry