Struct reqwest::async::Response

source ·
pub struct Response { /* private fields */ }
Expand description

A Response to a submitted Request.

Implementations

Get the final Url of this Response.

Get the remote address used to get this Response.

Get the StatusCode of this Response.

Get the Headers of this Response.

Get a mutable reference to the Headers of this Response.

Consumes the response, returning the body

Get a reference to the response body.

Get a mutable reference to the response body.

The chunks from the body may be decoded, depending on the gzip option on the ClientBuilder.

Get the HTTP Version of this Response.

Try to deserialize the response body as JSON using serde.

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)
            );
        }
    }
}

Trait Implementations

Formats the value using the given formatter. Read more
Converts to this type from the input type.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.