@eryx/http/body Module

JSON

Summary

Classes

StreamDecoder:write(data: string)string

Functions

body.decompress(body: string, encoding: string?)string
body.createDecoder(encoding: string?)StreamDecoder?

API Reference

Classes

StreamDecoder

An incremental HTTP content decoder returned by body.createDecoder.

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.

body.createDecoder(encoding: string?)StreamDecoder?

Parameters

encoding: string?

The Content-Encoding header value.

Returns

A decoder object, or nil when no decoding is required.