One ordered HTTP field occurrence, before normalization (RFC 9421 Section 2.1).
new/1 requires a map with :name, :value, and :section (:headers or
:trailers). Name case and every supplied value byte, including surrounding
whitespace and obs-text, remain unchanged. CR, LF, other controls, and obsolete
folding reject; capture must happen before an adapter discards that evidence.
Names are HTTP tokens of at most 256 bytes; values are at most 65,536 bytes.
Optional :provenance is :caller (default), :http1, :http2, or :http3.
It describes the caller's source, never authenticated transport evidence.
Unknown keys reject. validate/1 rechecks even manually modified structs.
Inspection is redacted; access fields explicitly when raw bytes are needed.
iex> {:ok, field} = RequestSeal.FieldOccurrence.new(%{name: "Accept", value: " text/plain", section: :headers})
iex> {field.name, field.value, field.section}
{"Accept", " text/plain", :headers}
iex> RequestSeal.FieldOccurrence.new(%{name: "bad name", value: "", section: :headers})
{:error, %RequestSeal.Message.Error{reason: :invalid_field}}
Summary
Functions
Construct a raw occurrence or return :invalid_field.
Check shape, source section, token syntax, raw value bytes, and bounds.
Types
Functions
@spec new(map()) :: {:ok, t()} | {:error, RequestSeal.Message.Error.t()}
Construct a raw occurrence or return :invalid_field.
@spec validate(term()) :: :ok | {:error, RequestSeal.Message.Error.t()}
Check shape, source section, token syntax, raw value bytes, and bounds.