pub struct Header<'a> { /* private fields */ }Expand description
A zero-copy view of a single HTTP header.
Implementations§
Source§impl<'a> Header<'a>
impl<'a> Header<'a>
Sourcepub fn name_bytes(&self) -> &'a [u8] ⓘ
pub fn name_bytes(&self) -> &'a [u8] ⓘ
Returns the header name as raw bytes.
Sourcepub fn as_bytes_pair(&self) -> (&'a [u8], &'a [u8])
pub fn as_bytes_pair(&self) -> (&'a [u8], &'a [u8])
Returns the header as a raw (&[u8], &[u8]) pair.
This is useful for zero-allocation header processing.
Sourcepub fn value_str(&self) -> Option<&'a str>
pub fn value_str(&self) -> Option<&'a str>
Returns the header value as a string, if valid UTF-8.
Sourcepub fn name_eq_ignore_case(&self, other: &str) -> bool
pub fn name_eq_ignore_case(&self, other: &str) -> bool
Returns true if this header name matches (case-insensitive).
Sourcepub fn is_content_length(&self) -> bool
pub fn is_content_length(&self) -> bool
Returns true if this is the Content-Length header.
Sourcepub fn is_transfer_encoding(&self) -> bool
pub fn is_transfer_encoding(&self) -> bool
Returns true if this is the Transfer-Encoding header.
Sourcepub fn as_content_length(&self) -> Option<usize>
pub fn as_content_length(&self) -> Option<usize>
Parses the value as Content-Length (usize).
Returns None if this isn’t Content-Length or value isn’t a valid integer.
Sourcepub fn is_chunked_encoding(&self) -> bool
pub fn is_chunked_encoding(&self) -> bool
Returns true if Transfer-Encoding is exactly “chunked” (case-insensitive, ignoring optional whitespace). We do NOT accept compound codings like “gzip, chunked” since the server does not support non-chunked transfer codings; rejecting them prevents request smuggling via unsupported intermediate codings.