engine/request_context/body

HTTP body parsing for gingee() middleware (json, form, multipart, raw). Engine-internal. Behavior must match the pre-extract gingee.js body path exactly except for documented hardening (media-type prefix, oversize destroy + 413).
Description:
  • HTTP body parsing for gingee() middleware (json, form, multipart, raw). Engine-internal. Behavior must match the pre-extract gingee.js body path exactly except for documented hardening (media-type prefix, oversize destroy + 413).

Methods

(inner) getContentTypeHeader(req) → {string}

Description:
  • First Content-Type header value (Node may give a string or string[]).
Parameters:
Name Type Description
req object
Returns:
Type
string

(async, inner) parseBodyAndRunHandler(store, handler, als) → {Promise.<void>}

Description:
  • Parse body (if any) and invoke handler with store.$g. Caller must have already set store.$g.request / response via initializeGContext.
Parameters:
Name Type Description
store object ALS store (must include req, res, $g, maxBodySize, logger, scriptPath)
handler function app script handler($g)
als object AsyncLocalStorage instance (same as modules/gingee.als)
Returns:
Type
Promise.<void>

(inner) parseMediaType(contentTypeHeader) → {string}

Description:
  • Media type only (type/subtype), lowercased — strips parameters such as charset/boundary. e.g. `application/json; charset=utf-8` → `application/json`
Parameters:
Name Type Description
contentTypeHeader string
Returns:
Type
string

(inner) requestLikelyHasBody(req) → {boolean}

Description:
  • True when the request likely carries a body (numeric content-length or chunked).
Parameters:
Name Type Description
req object
Returns:
Type
boolean