[−][src]Struct reqwest::async::Response
A Response to a submitted Request.
Implementations
impl Response[src]
pub fn status(&self) -> StatusCode[src]
Get the StatusCode of this Response.
pub fn headers(&self) -> &HeaderMap[src]
Get the Headers of this Response.
pub fn headers_mut(&mut self) -> &mut HeaderMap[src]
Get a mutable reference to the Headers of this Response.
pub fn cookies<'a>(&'a self) -> impl Iterator<Item = Cookie<'a>> + 'a[src]
Retrieve the cookies contained in the response.
Note that invalid 'Set-Cookie' headers will be ignored.
pub fn url(&self) -> &Url[src]
Get the final Url of this Response.
pub fn remote_addr(&self) -> Option<SocketAddr>[src]
Get the remote address used to get this Response.
pub fn content_length(&self) -> Option<u64>[src]
Get the content-length of this response, if known.
Reasons it may not be known:
- The server didn't send a
content-lengthheader. - The response is gzipped and automatically decoded (thus changing the actual decoded length).
pub fn into_body(self) -> Decoder[src]
Consumes the response, returning the body
pub fn body(&self) -> &Decoder[src]
Get a reference to the response body.
pub fn body_mut(&mut self) -> &mut Decoder[src]
Get a mutable reference to the response body.
The chunks from the body may be decoded, depending on the gzip
option on the ClientBuilder.
pub fn version(&self) -> Version[src]
Get the HTTP Version of this Response.
pub fn text(&mut self) -> impl Future<Item = String, Error = Error>[src]
Get the response text
pub fn text_with_charset(
&mut self,
default_encoding: &str
) -> impl Future<Item = String, Error = Error>[src]
&mut self,
default_encoding: &str
) -> impl Future<Item = String, Error = Error>
Get the response text given a specific encoding
pub fn json<T: DeserializeOwned>(
&mut self
) -> impl Future<Item = T, Error = Error>[src]
&mut self
) -> impl Future<Item = T, Error = Error>
Try to deserialize the response body as JSON using serde.
pub fn error_for_status(self) -> Result<Self>[src]
Turn a response into an error if the server returned an error.
Example
fn on_response(res: Response) { match res.error_for_status() { Ok(_res) => (), Err(err) => { // asserting a 400 as an example // it could be any status between 400...599 assert_eq!( err.status(), Some(reqwest::StatusCode::BAD_REQUEST) ); } } }
pub fn error_for_status_ref(&self) -> Result<&Self>[src]
Turn a reference to a response into an error if the server returned an error.
Example
fn on_response(res: &Response) { match res.error_for_status_ref() { Ok(_res) => (), Err(err) => { // asserting a 400 as an example // it could be any status between 400...599 assert_eq!( err.status(), Some(reqwest::StatusCode::BAD_REQUEST) ); } } }
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
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,