Skip to main content

decoded_body_accounting_middleware

Function decoded_body_accounting_middleware 

Source
pub(crate) async fn decoded_body_accounting_middleware(
    __arg0: State<ServerMemoryLimiter>,
    req: Request,
    next: Next,
) -> Response
Expand description

Route-local counterpart of memory_limit_middleware for routes that install RequestDecompressionLayer: it must be layered inside the decompression layer, so the body it wraps is the decompressed stream.

Only requests marked ContentEncoded by the global middleware are accounted; plain (uncompressed) requests are already covered by the global wire-byte accounting, and charging them here as well would double-count. For decompressed requests the Content-Length header has been stripped by the decompression layer, so the full decoded size is charged as it streams.