Net.HTTP.HeaderValue
The value of a header field, as it is sent: visible bytes, with spaces and tabs between them but not around them (RFC 9110 ยง5.5).
Invalid values are refused, never repaired. CR and LF would end the field and start another, and NUL ends a string in C code down the line, so a value holding one is an injection, not a typo; turning it into a space (as the RFC lets a recipient do) would hide that. Every other control byte and DEL are refused too. This holds for values a program writes as well as those that arrive: an outgoing value is checked as strictly as an incoming one.
A value is bytes. One that arrived is a view into the bytes its head
arrived in, not a copy, and may hold bytes above 0x7F that are not UTF-8,
which the wire allows. toString reads it as text.
Sensitive values. A value marked sensitive, as credentials are, shows
as <sensitive>, so printing a request or its headers does not print a
password. The mark is also what tells an HTTP/2 encoder never to index the
value.
Returns s as a header value, and panics if it is not one: a value written
in the program's source that is invalid is a mistake in the program.
Returns the value's text. A sensitive value's text too. Bytes that are not UTF-8 come back as U+FFFD; the bytes sent are the value's own, not this text's.
Returns v marked sensitive.
A field value: bytes[from..to), which no one writes to while the value is
alive. A value read off the wire is a view into the array its head arrived
in, which the codec hands over and never reuses; a value a program makes
views its string's own bytes.
The bytes may hold obs-text (0x80 and above) that is not UTF-8, since that
is a valid field value on the wire. text reads them as a string.
Values compare by their bytes; whether either is marked does not matter.
A sensitive value hides here too: its bytes are a credential.