Struct reqwest::header::Headers
[−]
[src]
pub struct Headers { /* fields omitted */ }
A map of header fields on requests and responses.
Methods
impl Headers
fn new() -> Headers
Creates a new, empty headers map.
fn set<H>(&mut self, value: H) where H: Header + HeaderFormat
Set a header field to the corresponding value.
The field is determined by the type of the value being set.
fn get_raw(&self, name: &str) -> Option<&[Vec<u8>]>
Access the raw value of a header.
Prefer to use the typed getters instead.
Example:
let raw_content_type = headers.get_raw("content-type");Run
fn set_raw<K>(&mut self, name: K, value: Vec<Vec<u8>>) where K: Into<Cow<'static, str>> + Debug
Set the raw value of a header, bypassing any typed headers.
Example:
headers.set_raw("content-length", vec![b"5".to_vec()]);Run
fn remove_raw(&mut self, name: &str)
Remove a header set by set_raw
fn get<H>(&self) -> Option<&H> where H: Header + HeaderFormat
Get a reference to the header field's value, if it exists.
fn get_mut<H>(&mut self) -> Option<&mut H> where H: Header + HeaderFormat
Get a mutable reference to the header field's value, if it exists.
fn has<H>(&self) -> bool where H: Header + HeaderFormat
Returns a boolean of whether a certain header is in the map.
Example:
let has_type = headers.has::<ContentType>();Run
fn remove<H>(&mut self) -> bool where H: Header + HeaderFormat
Removes a header from the map, if one existed. Returns true if a header has been removed.
fn iter(&self) -> HeadersItems
Returns an iterator over the header fields.
fn len(&self) -> usize
Returns the number of headers in the map.
fn clear(&mut self)
Remove all headers from the map.
Trait Implementations
impl<'a> Extend<HeaderView<'a>> for Headers
fn extend<I>(&mut self, iter: I) where I: IntoIterator<Item=HeaderView<'a>>
impl PartialEq<Headers> for Headers
impl Debug for Headers
impl Clone for Headers
fn clone(&self) -> Headers
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more