08 / EDGE
gunzip
Read a Content-Encoding: gzip body, inflate it, and hand the application the plain bytes, with an optional cap on the inflated size so a compression bomb stops at the limit rather than in memory.
WHERE IT SITS
INTERFACE
fn is_gzip_encoding(value : String) -> BoolfnWhether a Content-Encoding value asks for gzip. The header is a comma separated list and gzip may be one of several codings, so the match is on the token, not the whole value.
fn gunzip(limit~ : Int32 = 0) -> MiddlewarefnGunzip middleware: when the request declares Content-Encoding: gzip, buffer the body, inflate it, and hand the wrapped application one HttpRequest carrying the plain body. A body that will not inflate is answered 400 Bad Request without reaching the application. The application is handed a scope without Content-Encoding and without the compressed body's Content-Length: both describe bytes that no longer exist by the time it looks, and a handler that trusted either would misread the request. limit caps the *decompressed* size in bytes, the number a compression bomb inflates to; 0 removes the cap, which is what a service that has already bounded the compressed body at the edge wants. Anything but an HTTP scope, a request without the header, or one with no body at all passes through untouched.