An incremental HTTP content decoder returned by body.createDecoder.
@eryx/http/body Module
JSON
Summary
Classes
Functions
API Reference
Classes
StreamDecoder
Properties
StreamDecoder:write
StreamDecoder:write(data: string) → string
StreamDecoder:close
StreamDecoder:close() → ()
Functions
body.decompress
Decompresses an HTTP response body based on a Content-Encoding
header.
Supports stacked encodings such as "gzip, br", applying them in the
reverse order required by HTTP.
body.decompress(body: string, encoding: string?) → string
Parameters
body: string
The encoded response body bytes.
encoding: string?
The Content-Encoding header value.
Returns
string
The decoded body bytes.
body.createDecoder
Creates an incremental decoder for a Content-Encoding header value.
This is used by streamed HTTP responses so callers can consume decompressed data incrementally instead of buffering the whole encoded body first.
Parameters
encoding: string?
The Content-Encoding header value.
Returns
A decoder object, or nil when no decoding is required.