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"

copy

instantiate

(Fn [(Ref ETag a)] ETag)

copies a ETag.

delete

instantiate

(Fn [ETag] ())

deletes a ETag. Should usually not be called manually.

init

instantiate

(Fn [String, Bool] ETag)

creates a ETag.

parse

defn

(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.

prn

instantiate

(Fn [(Ref ETag a)] String)

converts a ETag to a string.

set-value

instantiate

(Fn [ETag, String] ETag)

sets the value property of a ETag.

set-value!

instantiate

(Fn [(Ref ETag a), String] ())

sets the value property of a ETag in place.

set-weak

instantiate

(Fn [ETag, Bool] ETag)

sets the weak property of a ETag.

set-weak!

instantiate

(Fn [(Ref ETag a), Bool] ())

sets the weak property of a ETag in place.

str

defn

(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?

defn

(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

instantiate

(Fn [ETag, (Ref (Fn [String] String a) b)] ETag)

updates the value property of a ETag using a function f.

update-weak

instantiate

(Fn [ETag, (Ref (Fn [Bool] Bool a) b)] ETag)

updates the weak property of a ETag using a function f.

value

instantiate

(Fn [(Ref ETag a)] (Ref String a))

gets the value property of a ETag.

weak

instantiate

(Fn [(Ref ETag a)] (Ref Bool a))

gets the weak property of a ETag.

weak-match?

defn

(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).