Documentation
¶
Overview ¶
Package contentcoding removes one HTTP content-coding (RFC 9110 §8.4.1) layer from a body: gzip (and its x-gzip alias), deflate, br and zstd. The coding names are the IANA HTTP Content Coding registry's, matched exactly after case folding — a protocol vocabulary, not a guess about the bytes.
The response normaliser (pkg/deparos/responsechain) decodes wire bodies through NewReader, and the store (pkg/database) decodes ingested bodies through Decode, so a body reads the same whichever path it took.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrTooLarge = errors.New("decoded body exceeds the size cap")
ErrTooLarge is returned by Decode when the decoded body exceeds its cap.
Functions ¶
func Decode ¶
Decode removes one coding layer from body, reading at most maxDecoded bytes of output (0 = no cap). It fails on an unsupported coding, on bytes that do not decode, on a stream that does not reach its end, and with ErrTooLarge past the cap — a caller storing the result keeps the original on any error rather than a fragment. "deflate" also accepts a raw (headerless) DEFLATE stream, which servers commonly send under that name.
func NewReader ¶
NewReader wraps r in a decoder for coding. An empty, "identity" or unknown coding returns r unchanged (wrapped to a ReadCloser), so a caller can pass any header value through. deflate is the zlib-wrapped form RFC 9110 names.
Types ¶
This section is empty.