pub struct Headers { /* private fields */ }Expand description
An immutable view of request headers
Implementations§
source§impl Headers
impl Headers
sourcepub fn get(&self, key: impl AsRef<str>) -> Option<&str>
pub fn get(&self, key: impl AsRef<str>) -> Option<&str>
Returns the value for a given key
If multiple values are associated, the first value is returned See HeaderMap::get
sourcepub fn get_all(&self, key: impl AsRef<str>) -> impl Iterator<Item = &str>
pub fn get_all(&self, key: impl AsRef<str>) -> impl Iterator<Item = &str>
Returns all values for a given key
sourcepub fn iter(&self) -> HeadersIter<'_> ⓘ
pub fn iter(&self) -> HeadersIter<'_> ⓘ
Returns an iterator over the headers
sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Returns true if this header is present
sourcepub fn insert(
&mut self,
key: impl AsHeaderComponent,
value: impl AsHeaderComponent
) -> Option<String>
pub fn insert( &mut self, key: impl AsHeaderComponent, value: impl AsHeaderComponent ) -> Option<String>
Insert a value into the headers structure.
This will replace any existing value for this key. Returns the previous associated value if any.
Panics
If the key or value are not valid ascii, this function will panic.
sourcepub fn try_insert(
&mut self,
key: impl AsHeaderComponent,
value: impl AsHeaderComponent
) -> Result<Option<String>, HttpError>
pub fn try_insert( &mut self, key: impl AsHeaderComponent, value: impl AsHeaderComponent ) -> Result<Option<String>, HttpError>
Insert a value into the headers structure.
This will replace any existing value for this key. Returns the previous associated value if any.
If the key or value are not valid ascii, an error is returned
sourcepub fn try_append(
&mut self,
key: impl AsHeaderComponent,
value: impl AsHeaderComponent
) -> Result<bool, HttpError>
pub fn try_append( &mut self, key: impl AsHeaderComponent, value: impl AsHeaderComponent ) -> Result<bool, HttpError>
Appends a value to a given key
If the key or value are NOT valid ascii, an error is returned