Struct http_types::headers::Headers[][src]

pub struct Headers { /* fields omitted */ }
Expand description

A collection of HTTP Headers.

Headers are never manually constructed, but are part of Request, Response, and Trailers. Each of these types implements AsRef<Headers> and AsMut<Headers> so functions that want to modify headers can be generic over either of these traits.

Examples

use http_types::{Response, StatusCode};

let mut res = Response::new(StatusCode::Ok);
res.insert_header("hello", "foo0");
assert_eq!(res["hello"], "foo0");

Implementations

Insert a header into the headers.

Not that this will replace all header values for a given header name. If you wish to add header values for a header name that already exists use Headers::append

Append a header to the headers.

Unlike insert this function will not override the contents of a header, but insert a header if there aren’t any. Or else append to the existing list of headers.

Get a reference to a header.

Get a mutable reference to a header.

Remove a header.

An iterator visiting all header pairs in arbitrary order.

An iterator visiting all header pairs in arbitrary order, with mutable references to the values.

An iterator visiting all header names in arbitrary order.

An iterator visiting all header values in arbitrary order.

Trait Implementations

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns a reference to the value corresponding to the supplied name.

Panics

Panics if the name is not present in Headers.

The returned type after indexing.

Returns a reference to the value corresponding to the supplied name.

Panics

Panics if the name is not present in Headers.

The returned type after indexing.

Returns a iterator of references over the remaining items.

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.