Struct rocket::http::Header [] [src]

pub struct Header<'h> {
    pub name: Cow<'h, str>,
    pub value: Cow<'h, str>,
}

Simple representation of an HTTP header.

Fields

The name of the header.

The value of the header.

Methods

impl<'h> Header<'h>
[src]

Constructs a new header. This method should be used rarely and only for non-standard headers. Instead, prefer to use the Into<Header> implementations of many types, including ContentType and all of the headers in http::hyper::header.

Examples

Create a custom header with name X-Custom-Header and value custom value.

use rocket::http::Header;

let header = Header::new("X-Custom-Header", "custom value");
assert_eq!(header.to_string(), "X-Custom-Header: custom value");

Use a String as a value to do the same.

use rocket::http::Header;

let value = format!("{} value", "custom");
let header = Header::new("X-Custom-Header", value);
assert_eq!(header.to_string(), "X-Custom-Header: custom value");

Trait Implementations

impl<'h> Debug for Header<'h>
[src]

Formats the value using the given formatter.

impl<'h> Clone for Header<'h>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<'h> Hash for Header<'h>
[src]

Feeds this value into the state given, updating the hasher as necessary.

Feeds a slice of this type into the state provided.

impl<'h> PartialEq for Header<'h>
[src]

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

This method tests for !=.

impl<'h> Eq for Header<'h>
[src]

impl<'h> Display for Header<'h>
[src]

Formats the value using the given formatter.

impl<T> From<T> for Header<'static> where T: Header + HeaderFormat
[src]

Performs the conversion.