Skip to main content

ResponseHead

Struct ResponseHead 

Source
pub struct ResponseHead {
    pub version: Version,
    pub status: StatusCode,
    pub headers: HeaderMap,
    pub headers_vec: Vec<HeaderItem>,
    pub reason: Option<&'static str>,
    /* private fields */
}
Expand description

The metadata for an HTTP response.

Fields§

§version: Version

HTTP protocol version.

§status: StatusCode

Response status code.

§headers: HeaderMap

Response headers.

§headers_vec: Vec<HeaderItem>

Headers in their original order and with their original names.

This collection is populated when decoding a response with HttpServiceConfig::set_headers_vec enabled.

§reason: Option<&'static str>

Custom reason phrase, or None to use the status code’s standard phrase.

Implementations§

Source§

impl ResponseHead

Source

pub fn new(status: StatusCode, version: Version) -> ResponseHead

Creates response metadata with the supplied status and HTTP version.

Source

pub fn extensions(&self) -> Ref<'_, Extensions>

Returns the response extensions.

Source

pub fn extensions_mut(&self) -> RefMut<'_, Extensions>

Returns mutable access to the response extensions.

Source

pub fn headers(&self) -> &HeaderMap

Returns the response headers.

Source

pub fn headers_mut(&mut self) -> &mut HeaderMap

Returns mutable access to the response headers.

Source

pub fn headers_vec(&self) -> &[HeaderItem]

Returns headers preserved in their original order and casing.

Source

pub fn set_connection_type(&mut self, ctype: ConnectionType)

Sets the response connection behavior.

Connection types are flags, and calling this method again does not clear a previously set type. When several are set, Close takes precedence over KeepAlive, which takes precedence over Upgrade.

Source

pub fn connection_type(&self) -> ConnectionType

Returns the response’s connection behavior.

Source

pub fn keep_alive(&self) -> bool

Returns whether the response keeps the connection open.

Source

pub fn upgrade(&self) -> bool

Returns whether the response upgrades the connection.

Source

pub fn reason(&self) -> &str

Returns the custom or canonical reason phrase.

The reason phrase is empty for a status code without a canonical reason.

Source

pub fn chunked(&self) -> bool

Returns whether HTTP/1 chunked transfer encoding is allowed.

Source

pub fn no_chunking(&mut self, val: bool)

Enables or disables HTTP/1 chunked transfer encoding.

Trait Implementations§

Source§

impl Debug for ResponseHead

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ResponseHead

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'a> From<&'a ResponseHead> for ResponseBuilder

Convert ResponseHead to a ResponseBuilder

Source§

fn from(head: &'a ResponseHead) -> ResponseBuilder

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.