Skip to main content

Function: readBunBody()

readBunBody(req, rawRequest, maxBodySize?): Promise<ReadBunBodyResult>

Defined in: service-core/src/http/bun/BunAdapters.ts:323

Reads the full request body from a Bun Request into a Buffer, mirroring readBody()'s uWS behavior exactly: body parsing (JSON / URL-encoded) is applied based on content-type and the result is cached on req.body / req.rawBody. Rejects with a 413 JSON Response if the body exceeds maxBodySize — checked both against the declared Content-Length up front (fast path) and against the actual accumulated byte count as chunks arrive, so chunked/unknown-length bodies that lie about or omit Content-Length are still caught, matching uWS's guarantee.

Parameters

req

BunRequest

rawRequest

Request

maxBodySize?

number = DEFAULT_MAX_BODY_SIZE

Returns

Promise<ReadBunBodyResult>