Module Spindle_http.Etag

Entity tags, as RFC 9110 §8.8.3 writes them, and the two ways §8.8.3.2 compares them.

Etag.parse {|W/"xyzzy"|} = Ok { weak = true; opaque = "xyzzy" }
Etag.condition {|"a", W/"b"|} = Ok (Tags [ ...; ... ])

An opaque tag may hold a comma, so a list of them is read by this grammar and never split where a comma is.

type t = {
  1. weak : bool;
    (*

    written W/"...": a representation equivalent, not identical

    *)
  2. opaque : string;
    (*

    what is between the quotes: etagc, RFC 9110's visible characters but DQUOTE, and obs-text

    *)
}
val parse : string -> (t, string) Stdlib.result

One entity tag, and the whitespace around it.

val to_string : t -> (string, string) Stdlib.result

W/"opaque" or "opaque", as parse reads it back, or Error for an opaque tag holding a quote, a space or a control character.

val strong_equal : t -> t -> bool

Both strong, and the same opaque tag: what If-Match and If-Range ask.

val weak_equal : t -> t -> bool

The same opaque tag, either weak or not: what If-None-Match asks.

type condition =
  1. | Any
    (*

    *

    *)
  2. | Tags of t list

What If-Match and If-None-Match hold.

val condition : string -> (condition, string) Stdlib.result

A field's value, its lines joined with commas as RFC 9110 §5.3 allows.