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: VersionHTTP protocol version.
status: StatusCodeResponse status code.
headers: HeaderMapResponse 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
impl ResponseHead
Sourcepub fn new(status: StatusCode, version: Version) -> ResponseHead
pub fn new(status: StatusCode, version: Version) -> ResponseHead
Creates response metadata with the supplied status and HTTP version.
Sourcepub fn extensions(&self) -> Ref<'_, Extensions>
pub fn extensions(&self) -> Ref<'_, Extensions>
Returns the response extensions.
Sourcepub fn extensions_mut(&self) -> RefMut<'_, Extensions>
pub fn extensions_mut(&self) -> RefMut<'_, Extensions>
Returns mutable access to the response extensions.
Sourcepub fn headers_mut(&mut self) -> &mut HeaderMap
pub fn headers_mut(&mut self) -> &mut HeaderMap
Returns mutable access to the response headers.
Sourcepub fn headers_vec(&self) -> &[HeaderItem]
pub fn headers_vec(&self) -> &[HeaderItem]
Returns headers preserved in their original order and casing.
Sourcepub fn set_connection_type(&mut self, ctype: ConnectionType)
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.
Sourcepub fn connection_type(&self) -> ConnectionType
pub fn connection_type(&self) -> ConnectionType
Returns the response’s connection behavior.
Sourcepub fn keep_alive(&self) -> bool
pub fn keep_alive(&self) -> bool
Returns whether the response keeps the connection open.
Sourcepub fn reason(&self) -> &str
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.
Sourcepub fn no_chunking(&mut self, val: bool)
pub fn no_chunking(&mut self, val: bool)
Enables or disables HTTP/1 chunked transfer encoding.
Trait Implementations§
Source§impl Debug for ResponseHead
impl Debug for ResponseHead
Source§impl Default for ResponseHead
impl Default for ResponseHead
Source§impl<'a> From<&'a ResponseHead> for ResponseBuilder
Convert ResponseHead to a ResponseBuilder
impl<'a> From<&'a ResponseHead> for ResponseBuilder
Convert ResponseHead to a ResponseBuilder