ContentEncoding
Enum ContentEncoding.
Description
Represents common and experimental HTTP Content-Encoding header values. Content-Encoding defines the compression mechanism applied to the HTTP message body. Implementations using this enum MUST follow the semantics defined in RFC 7231, RFC 9110, and the relevant algorithm RFCs.
Each encoding describes a specific compression algorithm or an identity transformation. Servers and intermediaries using this enum SHOULD ensure that content negotiation is performed safely and consistently according to client capabilities, honoring q-values and alias mappings.
Cases
A format using the Brotli compression algorithm.
A format using the Lempel-Ziv-Welch (LZW) algorithm.
Experimental: A format using the Dictionary-Compressed Brotli algorithm.
Experimental: A format using the Dictionary-Compressed Zstandard algorithm.
A format using the zlib framing structure (RFC 1950) with the DEFLATE compression algorithm (RFC 1951).
A format using the Lempel-Ziv coding (LZ77) with a 32-bit CRC.
Indicates the identity function (no compression).
A format using the Zstandard compression algorithm.
Methods
Determines whether a given encoding is acceptable according to an `Accept-Encoding` header value.
Returns known alias names for a given encoding.
A format using the Lempel-Ziv coding (LZ77) with a 32-bit CRC.
Description
The HTTP/1.1 standard states that servers supporting this encoding
SHOULD also recognize "x-gzip" as an alias for compatibility.
Implementations consuming this enum MUST treat both forms as
equivalent during content negotiation.
A format using the Lempel-Ziv-Welch (LZW) algorithm.
Description
Historically derived from the UNIX compress program. This encoding
is largely obsolete in modern HTTP contexts and SHOULD NOT be used
except for legacy interoperation.
A format using the zlib framing structure (RFC 1950) with the DEFLATE compression algorithm (RFC 1951).
Description
This encoding MUST NOT be confused with “raw deflate” streams.
A format using the Brotli compression algorithm.
Description
Defined in RFC 7932, Brotli provides modern general-purpose compression and SHOULD be preferred over older schemes such as gzip when client support is present.
A format using the Zstandard compression algorithm.
Description
Defined in RFC 8878, Zstandard (“zstd”) offers high compression ratios and fast decompression. Implementations MAY use dictionary compression where supported by the protocol extension.
Indicates the identity function (no compression).
Description
The identity encoding MUST be considered acceptable if the client omits an Accept-Encoding header. It MUST NOT apply any compression transformation to the content.
Experimental: A format using the Dictionary-Compressed Brotli algorithm.
Description
See the Compression Dictionary Transport specification. This encoding is experimental and MAY NOT be supported by all clients.
Experimental: A format using the Dictionary-Compressed Zstandard algorithm.
Description
See the Compression Dictionary Transport specification. This encoding is experimental and MAY NOT be supported by all clients.
Determines whether a given encoding is acceptable according to an `Accept-Encoding` header value.
public
static
isSupported(
self
$encoding,
string
$acceptEncodingHeader) : bool
Description
This method MUST correctly apply HTTP content negotiation rules:
- Parse q-values, which MUST determine the client's preference level.
- Interpret “q=0” as explicit rejection.
- Support wildcards (“*”) as fallback.
- Recognize “x-gzip” as an alias for the gzip encoding. If an encoding is not explicitly listed and no wildcard is present, the encoding SHOULD be considered acceptable unless the header exclusively lists explicit rejections.
Parameters
$encoding
:
self
Description
the encoding to evaluate
$acceptEncodingHeader
:
string
Description
the raw Accept-Encoding header value
Return values
Description
true if the encoding is acceptable according to negotiation rules
Returns known alias names for a given encoding.
private
static
getAliases(
self
$encoding) : array<string|int, string>
Description
Implementations MUST treat aliases as equivalent when performing content negotiation. Currently only gzip uses an alias (“x-gzip”), but future extensions MAY introduce additional aliases.
Parameters
$encoding
:
self
Description
the encoding whose aliases will be returned
Return values
Description
a list of lowercase alias identifiers