body.inflate — Automatic decompression
body.inflate enables the middleware to accept compressed request payloads and transparently decompress them before parsing. Supported encodings:
gzipdeflatebr(Brotli)
Default
inflate: trueby default (recommended).
Behavior
- If
inflateistrueand the request includesContent-Encoding: gzip|deflate|br, the middleware will attempt to decompress the stream and then parse it according toContent-Type. - If decompression fails, the middleware returns
400 Invalid Compressed Data. - If
inflateisfalseand the request is compressed, the middleware returns415 Unsupported Content-Encoding.
Example
// Accept gzipped JSON payloads
parseData({ body: { inflate: true, type: "application/json" } })Security and limits
- Decompression is applied after
security.verifycompletes (soverifysees the original bytes whenbody.raw: true). - Be careful with decompression bombs — always use
limitto bound memory usage. - Use streaming decompression internally; parseData handles async-safe stream reading.
Best practices
- Keep
inflate: trueif you expect clients to send compressed requests. - Combine with
limitand a reasonable timeout at the server level to avoid resource exhaustion.