pub async fn transform_request_body<B>(
body: B,
compiled: &CompiledJsonTransform,
headers: &HeaderMap,
) -> RequestBodyOutcome<B>Expand description
The REQUEST body transform (DW-028): gate, buffer (capped), parse,
apply ops, serialize. Gates in order, cheapest first — no compiled
policy (the caller’s None check), then here: non-JSON content
type (bodies of other types stream through untouched), an
already-encoded body (the transform does not decode), a declared
empty body (nothing to transform — bodiless methods pass), and a
declared length over the cap (413 without reading a byte). Only
then does anything buffer.
Reading the body here preserves every wrapper beneath it: the route’s limit counting guard and the HMAC digest fold still see the ORIGINAL client bytes (the digest binds what the client signed; the transform then shapes what the upstream receives — enforcement and policy are separable by design).