ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

Ecluse.Core.Server.Encoding

Description

Content-coding negotiation for served metadata, read from every Accept-Encoding field (RFC 9110, section 12.5.3). Écluse offers gzip and identity, and reads x-gzip as gzip, as RFC 9110 section 8.4.1.3 asks of a recipient. Gzip wins a tie of positive qualities, a malformed quality refuses its coding, and a refusal beats a duplicate offer. A request that excludes both codings takes 406. Identity-only metadata ignores the field.

Synopsis

The operator's setting

data MetadataCompression Source #

Whether served metadata may be gzipped for a client that accepts it.

Constructors

GzipWhenAccepted

Gzip a listing when the request's Accept-Encoding prefers it.

IdentityOnly

Serve every listing in identity coding and ignore Accept-Encoding.

Negotiation

data ContentCoding Source #

A content coding Écluse can serve a listing in.

Constructors

IdentityCoding 
GzipCoding 

data CodingChoice Source #

The coding a request selects, or the refusal when it excludes every coding Écluse serves.

Instances

Instances details
Show CodingChoice Source # 
Instance details

Defined in Ecluse.Core.Server.Encoding

Eq CodingChoice Source # 
Instance details

Defined in Ecluse.Core.Server.Encoding

chooseCoding :: MetadataCompression -> RequestHeaders -> CodingChoice Source #

Select a listing's coding. Identity stays acceptable unless excluded, and outranks gzip only by an explicit higher quality.

Response headers

gzipEncodingHeader :: Header Source #

The Content-Encoding header of a gzip listing.

varyAcceptEncoding :: ResponseHeaders -> ResponseHeaders Source #

Add Accept-Encoding to a response's Vary, keeping the field names already listed.