| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Core.Server.Conditional
Description
Conditional-GET and ETag handling, split by how the served body relates to upstream's.
A pass-through body (an artifact) is upstream's bytes, so the client's validators are relayed
upstream and an upstream 304 is passed back. A merged listing on the packument path takes our own
ETag, derived from the serve's inputs rather than hashed over its output. It can be stale only in
the safe direction (a spurious 200, never a wrong 304), and a 304 costs no assembly. RubyGems
Compact Index replies and compact specifications hash their rendered identity bytes instead, so a
304 skips compression but still pays the fetch, merge or serialisation.
Synopsis
- data ETag
- mkStrongETag :: Digest SHA256 -> ETag
- mkWeakETag :: Digest SHA256 -> ETag
- renderETag :: ETag -> Text
- etagHeader :: ETag -> Header
- data Conditional
- evaluateETag :: RequestHeaders -> ETag -> Conditional
- forwardValidators :: RequestHeaders -> RequestHeaders
- isNotModified :: Status -> Bool
Our own ETag (transformed bodies)
An entity tag in the wire form the ETag header carries, kept apart from the bare digest.
mkStrongETag :: Digest SHA256 -> ETag Source #
Quote a SHA-256 fingerprint, hex-encoded, as a strong ETag: one exact byte representation.
mkWeakETag :: Digest SHA256 -> ETag Source #
A weak ETag over a fingerprint, for a representation whose exact bytes the codec may change.
renderETag :: ETag -> Text Source #
The ETags wire form, the quoted opaque tag as it goes into the header.
etagHeader :: ETag -> Header Source #
The ETag response header carrying this validator.
data Conditional Source #
Whether the client's validator already matches the transformed body we would serve.
Constructors
| NotModified ETag | Unchanged from the client's validator: answer |
| Modified ETag | Changed, or no validator was sent: serve |
Instances
| Show Conditional Source # | |
Defined in Ecluse.Core.Server.Conditional Methods showsPrec :: Int -> Conditional -> ShowS # show :: Conditional -> String # showList :: [Conditional] -> ShowS # | |
| Eq Conditional Source # | |
Defined in Ecluse.Core.Server.Conditional | |
evaluateETag :: RequestHeaders -> ETag -> Conditional Source #
Compare weakly (RFC 9110) against our own ETag. A merge has no single timestamp, so If-Modified-Since is ignored.
Relaying validators (pass-through bodies)
forwardValidators :: RequestHeaders -> RequestHeaders Source #
The only two client headers relayed upstream for a pass-through body, so upstream can answer 304.
isNotModified :: Status -> Bool Source #
Whether a pass-through upstream response is a 304 to pass back, upstream's own validator having decided.