Skip to content

Taxum / @taxum/core / http / Encoding

Class: Encoding

Defined in: http/content-encoding.ts:25

Represents various content encodings used for compression and decompression.

This class is used to define well-known encoding formats, provide functionality for parsing and resolving encodings based on client preferences or available support and determine the preferred encoding from a list of accepted encodings.

Encodings are defined as static constants in this class, such as GZIP, DEFLATE, etc. Each encoding includes a string identifier and an optional file extension.

Instances of this class cannot be directly instantiated and must be accessed via the static constants or methods provided.

Properties

fileExtension

readonly fileExtension: null | string

Defined in: http/content-encoding.ts:40

File extension associated with the encoding, if any.


value

readonly value: string

Defined in: http/content-encoding.ts:35

Value of the encoding as represented in headers.


BROTLI

readonly static BROTLI: Encoding

Defined in: http/content-encoding.ts:29


DEFLATE

readonly static DEFLATE: Encoding

Defined in: http/content-encoding.ts:27


GZIP

readonly static GZIP: Encoding

Defined in: http/content-encoding.ts:28


IDENTITY

readonly static IDENTITY: Encoding

Defined in: http/content-encoding.ts:26


ZSTD

readonly static ZSTD: Encoding

Defined in: http/content-encoding.ts:30

Methods

fromHeaders()

static fromHeaders(headers, supportedEncodings): Encoding

Defined in: http/content-encoding.ts:80

Determines the preferred encoding from the provided headers and supported encodings.

Parameters

headers

HeaderMap

supportedEncodings

SupportedEncodings

Returns

Encoding


preferredEncoding()

static preferredEncoding(acceptedEncodings): null | Encoding

Defined in: http/content-encoding.ts:93

Determines the preferred encoding from a list of accepted encodings and their associated quality values.

Parameters

acceptedEncodings

[Encoding, number][]

Returns

null | Encoding