pub fn header_value_from_raw(raw: impl Into<Bytes>) -> HeaderValueExpand description
Build a HeaderValue from owned bytes, normalizing the value per RFC
9110 section 5.5 and RFC 9112 section 5.2: obs-fold continuations
collapse to a single SP, and any stray CR / LF / NUL is replaced with SP.
Zero-copy when the input contains no CR/LF/NUL.
§Precondition
Input must come from a conformant HTTP/1.1 parser: bytes must satisfy
the field-content grammar (SP, HTAB, %x21-7E, obs-text %x80-FF),
with CR/LF/NUL only appearing as part of an obs-fold or as invalid bytes
that this function will replace with SP. All workspace callers satisfy
this via httparse.
§Panics
Debug builds panic on precondition violation via the sanity check in
HeaderValue::from_maybe_shared_unchecked. Release builds skip the
check; invalid input is undefined behavior per the http crate.