pub struct Response { /* private fields */ }
Expand description
A Response to a submitted Request
.
Implementations§
source§impl Response
impl Response
sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Get the StatusCode
of this Response
.
sourcepub fn headers_mut(&mut self) -> &mut HeaderMap
pub fn headers_mut(&mut self) -> &mut HeaderMap
Get a mutable reference to the Headers
of this Response
.
sourcepub fn content_length(&self) -> Option<u64>
pub fn content_length(&self) -> Option<u64>
Get the content-length of this response, if known.
Reasons it may not be known:
- The server didn’t send a
content-length
header. - The response is compressed and automatically decoded (thus changing the actual decoded length).
sourcepub async fn json<T: DeserializeOwned>(self) -> Result<T>
Available on crate feature json
only.
pub async fn json<T: DeserializeOwned>(self) -> Result<T>
json
only.Try to deserialize the response body as JSON.
sourcepub fn bytes_stream(self) -> impl Stream<Item = Result<Bytes>>
pub fn bytes_stream(self) -> impl Stream<Item = Result<Bytes>>
Convert the response into a Stream
of Bytes
from the body.
sourcepub fn error_for_status(self) -> Result<Self>
pub fn error_for_status(self) -> Result<Self>
Turn a response into an error if the server returned an error.
sourcepub fn error_for_status_ref(&self) -> Result<&Self>
pub fn error_for_status_ref(&self) -> Result<&Self>
Turn a reference to a response into an error if the server returned an error.