pub struct Response { /* private fields */ }
Expand description
Represents an HTTP response
Implementations
sourceimpl Response
impl Response
sourcepub fn headers_mut(&mut self) -> &mut HeaderMap
pub fn headers_mut(&mut self) -> &mut HeaderMap
Get mutable headers reference.
sourcepub fn set_headers(&mut self, headers: HeaderMap)
pub fn set_headers(&mut self, headers: HeaderMap)
Set headers.
sourcepub fn add_header<N, V>(
&mut self,
name: N,
value: V,
overwrite: bool
) -> Result<()>where
N: IntoHeaderName,
V: TryInto<HeaderValue>,
pub fn add_header<N, V>(
&mut self,
name: N,
value: V,
overwrite: bool
) -> Result<()>where
N: IntoHeaderName,
V: TryInto<HeaderValue>,
Modify a header for this response.
When overwrite
is set to true
, If the header is already present, the value will be replaced.
When overwrite
is set to false
, The new header is always appended to the request, even if the header already exists.
sourcepub fn with_header<N, V>(
&mut self,
name: N,
value: V,
overwrite: bool
) -> Result<&mut Self>where
N: IntoHeaderName,
V: TryInto<HeaderValue>,
pub fn with_header<N, V>(
&mut self,
name: N,
value: V,
overwrite: bool
) -> Result<&mut Self>where
N: IntoHeaderName,
V: TryInto<HeaderValue>,
Modify a header for this response.
When overwrite
is set to true
, If the header is already present, the value will be replaced.
When overwrite
is set to false
, The new header is always appended to the request, even if the header already exists.
sourcepub fn version_mut(&mut self) -> &mut Version
pub fn version_mut(&mut self) -> &mut Version
Get mutable version reference.
sourcepub fn replace_body(&mut self, body: Body) -> Body
pub fn replace_body(&mut self, body: Body) -> Body
Set body to a new value and returns old value.
Available on crate feature cookie
only.
cookie
only.Get cookies reference.
Available on crate feature cookie
only.
cookie
only.Get mutable cookies reference.
Available on crate feature cookie
only.
cookie
only.Helper function for get cookie.
Available on crate feature cookie
only.
cookie
only.Helper function for add cookie.
Available on crate feature cookie
only.
cookie
only.Helper function for add cookie.
Available on crate feature cookie
only.
cookie
only.Helper function for remove cookie.
sourcepub fn status_code(&self) -> Option<StatusCode>
pub fn status_code(&self) -> Option<StatusCode>
Get status code.
sourcepub fn set_status_code(&mut self, code: StatusCode)
pub fn set_status_code(&mut self, code: StatusCode)
Set status code.
sourcepub fn with_status_code(&mut self, code: StatusCode) -> &mut Self
pub fn with_status_code(&mut self, code: StatusCode) -> &mut Self
Set status code.
sourcepub fn content_type(&self) -> Option<Mime>
pub fn content_type(&self) -> Option<Mime>
Get content type.
sourcepub fn status_error(&self) -> Option<&StatusError>
pub fn status_error(&self) -> Option<&StatusError>
Get http error if exists, only exists after use set_status_error
set http error.
sourcepub fn set_status_error(&mut self, err: StatusError)
pub fn set_status_error(&mut self, err: StatusError)
Set http error.
sourcepub fn with_status_error(&mut self, err: StatusError) -> &mut Self
pub fn with_status_error(&mut self, err: StatusError) -> &mut Self
Set http error.
sourcepub fn with_render<P>(&mut self, piece: P) -> &mut Selfwhere
P: Piece,
pub fn with_render<P>(&mut self, piece: P) -> &mut Selfwhere
P: Piece,
Render content.
sourcepub fn stuff<P>(&mut self, code: StatusCode, piece: P)where
P: Piece,
pub fn stuff<P>(&mut self, code: StatusCode, piece: P)where
P: Piece,
Render content with status code.
sourcepub fn with_stuff<P>(&mut self, code: StatusCode, piece: P) -> &mut Selfwhere
P: Piece,
pub fn with_stuff<P>(&mut self, code: StatusCode, piece: P) -> &mut Selfwhere
P: Piece,
Render content with status code.
Trait Implementations
sourceimpl ResponseExt for Response
Available on crate feature test
only.
impl ResponseExt for Response
test
only.sourcefn take_string<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn take_string<'life0, 'async_trait>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
String
from response.sourcefn take_json<'life0, 'async_trait, T>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned,
'life0: 'async_trait,
Self: 'async_trait,
fn take_json<'life0, 'async_trait, T>(
&'life0 mut self
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>where
T: 'async_trait + DeserializeOwned,
'life0: 'async_trait,
Self: 'async_trait,
T
instance.sourcefn take_string_with_charset<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
charset: &'life1 str,
compress: Option<&'life2 str>
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn take_string_with_charset<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
charset: &'life1 str,
compress: Option<&'life2 str>
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
String
from response with charset.