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 callstate.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 asstring
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, a400 INVALID
response will be sent.__proto__
andconstructor.prototype
are also checked.www-form-urlencoded
andwww-form-urlencoded-urlsearchparams
- Parse the body using
URLSearchParams
optionally callingObject.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);