ETag
is an entity-tag (RFC 9110 §8.8.3): the opaque value a server sends
in an ETag header to name one version of a representation, and weak, whether
it carried the W/ prefix that marks it as a weak validator. value is held
without its surrounding quotes.
(ETag.str &(ETag.init @"xyzzy" false)) ; => "xyzzy"
(ETag.str &(ETag.init @"xyzzy" true)) ; => W/"xyzzy"
parse
(Fn [(Ref String a)] (Result ETag String))
(parse s)
parses one entity-tag (RFC 9110 §8.8.3) as
(Result ETag String).
Both forms are read: the strong "xyzzy" and the weak W/"xyzzy". The W/
prefix is case-sensitive, as §8.8.3's grammar has it, so a lowercase w/ is not
a weak tag but a malformed one. Whitespace around the tag is ignored. An
unquoted tag, an unterminated one, and one whose opaque-tag holds a byte
etagc has no room for — a control character, a space or a quote — all fail.
str
(Fn [(Ref ETag a)] String)
(str e)
serializes e back into an entity-tag, e.g. W/"xyzzy".
Anything parse produced reads back into an equal ETag; a hand-built
value holding a quote or a control character writes a tag parse rejects.
strong-match?
(Fn [(Ref ETag a), (Ref ETag a)] Bool)
(strong-match? a b)
compares a and b with the strong comparison function
of RFC 9110 §8.8.3.2: they match only when neither is weak and their opaque
values are byte-identical. It is what If-Match uses (§13.1.1). A weak tag
never matches strongly, not even itself.
update-value
(Fn [ETag, (Ref (Fn [String] String a) b)] ETag)
updates the value property of a ETag using a function f.
update-weak
(Fn [ETag, (Ref (Fn [Bool] Bool a) b)] ETag)
updates the weak property of a ETag using a function f.
weak-match?
(Fn [(Ref ETag a), (Ref ETag a)] Bool)
(weak-match? a b)
compares a and b with the weak comparison function of
RFC 9110 §8.8.3.2: they match whenever their opaque values are byte-identical,
however either one is marked. It is what If-None-Match uses (§13.1.2).