Struct rocket::http::Header [−][src]
Expand description
Simple representation of an HTTP header.
Fields
name: Uncased<'h>
The name of the header.
value: Cow<'h, str>
The value of the header.
Implementations
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");
Returns the name of this header.
Example
A case-sensitive equality check:
use rocket::http::Header; let value = format!("{} value", "custom"); let header = Header::new("X-Custom-Header", value); assert_eq!(header.name().as_str(), "X-Custom-Header"); assert_ne!(header.name().as_str(), "X-CUSTOM-HEADER");
A case-insensitive equality check:
use rocket::http::Header; let header = Header::new("X-Custom-Header", "custom value"); assert_eq!(header.name(), "X-Custom-Header"); assert_eq!(header.name(), "X-CUSTOM-HEADER");
Trait Implementations
Creates a new Header
with name Content-Type
and the value set to the
HTTP rendering of this Content-Type.
Creates a new Header
with name Accept
and the value set to the HTTP
rendering of this Accept
header.
Auto Trait Implementations
impl<'h> RefUnwindSafe for Header<'h>
impl<'h> UnwindSafe for Header<'h>
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Converts self
into a collection.
type Output = T
type Output = T
Should always be Self
pub fn vzip(self) -> V