Skip to main content

decoded_body_accounting_middleware

Function decoded_body_accounting_middleware 

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

Route-local accounting for routes that install RequestDecompressionLayer: it must be layered inside the decompression layer, so the body it wraps is the decompressed stream. It requires the global accounting installed by crate::http::HttpServer and must use the same ServerMemoryLimiter.

Only encoded requests marked 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.