Struct reqwest::async::Response[][src]

pub struct Response { /* fields omitted */ }

A Response to a submitted Request.

Methods

impl Response
[src]

Get the final Url of 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

impl Debug for Response
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for Response

impl !Sync for Response