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 version_mut(&mut self) -> &mut Version
pub fn version_mut(&mut self) -> &mut Version
Get mutable version reference.
sourcepub async fn take_json<T: DeserializeOwned>(&mut self) -> Result<T>
pub async fn take_json<T: DeserializeOwned>(&mut self) -> Result<T>
Take body from response.
sourcepub async fn take_text_with_charset(
&mut self,
default_charset: &str
) -> Result<String>
pub async fn take_text_with_charset(
&mut self,
default_charset: &str
) -> Result<String>
Take body as String
from response with charset.
sourcepub async fn take_bytes(&mut self) -> Result<Bytes>
pub async fn take_bytes(&mut self) -> Result<Bytes>
Take body bytes from response.
Get cookies reference.
Get mutable cookies reference.
Helper function for get cookie.
Helper function for add cookie.
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 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 render<P>(&mut self, piece: P) where
P: Piece,
pub fn render<P>(&mut self, piece: P) where
P: Piece,
Render text as html content. It will set content-type
to text/html; charset=utf-8
.
sourcepub fn write_body(&mut self, data: &[u8]) -> Result<()>
pub fn write_body(&mut self, data: &[u8]) -> Result<()>
Write bytes data to body. If body is none, a new Body
will created.
sourcepub fn streaming<S, O, E>(&mut self, stream: S) -> Result<()> where
S: Stream<Item = Result<O, E>> + Send + 'static,
O: Into<Bytes> + 'static,
E: Into<Box<dyn StdError + Send + Sync>> + 'static,
pub fn streaming<S, O, E>(&mut self, stream: S) -> Result<()> where
S: Stream<Item = Result<O, E>> + Send + 'static,
O: Into<Bytes> + 'static,
E: Into<Box<dyn StdError + Send + Sync>> + 'static,
Write streaming data.
sourcepub fn redirect_temporary<U: AsRef<str>>(&mut self, url: U)
pub fn redirect_temporary<U: AsRef<str>>(&mut self, url: U)
Redirect temporary.
sourcepub fn redirect_found<U: AsRef<str>>(&mut self, url: U)
pub fn redirect_found<U: AsRef<str>>(&mut self, url: U)
Redirect found.
sourcepub fn redirect_other<U: AsRef<str>>(
&mut self,
url: U
) -> Result<(), InvalidHeaderValue>
pub fn redirect_other<U: AsRef<str>>(
&mut self,
url: U
) -> Result<(), InvalidHeaderValue>
Redirect other.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Response
impl Send for Response
impl !Sync for Response
impl Unpin for Response
impl !UnwindSafe for Response
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more