This page is part of a static HTML representation of the TiddlyWiki at https://mws.tiddlywiki.com/

Body Format

14th May 2025 at 1:43am
ignore
state.data will be undefined. state.reader will be draining or already closed.
stream
state.data will be undefined. You must call state.reader to get the request.
buffer
state.data will be a Buffer.
string
state.data will be a string.
json
state.data will be read as a string, same as string and then parsed as JSON, with some sanity checks. If the string is zero-length, undefined will be returned without attempting to parse. This is the only case where undefined can be returned. If the JSON fails to parse, a 400 INVALID response will be sent. __proto__ and constructor.prototype are also checked.
www-form-urlencoded and www-form-urlencoded-urlsearchparams
Parse the body using URLSearchParams optionally calling Object.entries on it.
const data = state.data = new URLSearchParams((await state.readBody()).toString("utf8"));
if (state.bodyFormat === "www-form-urlencoded") state.data = Object.fromEntries(data);