Struct hyper::header::Headers [] [src]

pub struct Headers { /* fields omitted */ }

A map of header fields on requests and responses.

Methods

impl Headers
[src]

Creates a new, empty headers map.

Set a header field to the corresponding value.

The field is determined by the type of the value being set.

Get a reference to the header field's value, if it exists.

Get a mutable reference to the header field's value, if it exists.

Returns a boolean of whether a certain header is in the map.

Example:

let has_type = headers.has::<ContentType>();

Removes a header from the map, if one existed. Returns the header, if one has been removed and could be parsed.

Note that this function may return None even though a header was removed. If you want to know whether a header exists, rather rely on has.

Returns an iterator over the header fields.

Returns the number of headers in the map.

Remove all headers from the map.

Access the raw value of a header.

Prefer to use the typed getters instead.

Example:

let raw = headers.get_raw("content-type").unwrap();
assert_eq!(raw, "text/plain");

Set the raw value of a header, bypassing any typed headers.

Example:

headers.set_raw("content-length", b"1".as_ref());
headers.set_raw("content-length", "2");
headers.set_raw("content-length", "3".to_string());
headers.set_raw("content-length", vec![vec![b'4']]);

Remove a header by name.

Trait Implementations

impl Clone for Headers
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Default for Headers
[src]

Returns the "default value" for a type. Read more

impl PartialEq for Headers
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Display for Headers
[src]

Formats the value using the given formatter.

impl Debug for Headers
[src]

Formats the value using the given formatter.

impl<'a> Extend<HeaderView<'a>> for Headers
[src]

Extends a collection with the contents of an iterator. Read more

impl<'a> FromIterator<HeaderView<'a>> for Headers
[src]

Creates a value from an iterator. Read more