Struct reqwest::async::Response [−][src]
pub struct Response { /* fields omitted */ }
A Response to a submitted Request
.
Methods
impl Response
[src]
impl Response
pub fn url(&self) -> &Url
[src]
pub fn url(&self) -> &Url
Get the final Url
of this Response
.
pub fn status(&self) -> StatusCode
[src]
pub fn status(&self) -> StatusCode
Get the StatusCode
of this Response
.
pub fn headers(&self) -> &HeaderMap
[src]
pub fn headers(&self) -> &HeaderMap
Get the Headers
of this Response
.
pub fn headers_mut(&mut self) -> &mut HeaderMap
[src]
pub fn headers_mut(&mut self) -> &mut HeaderMap
Get a mutable reference to the Headers
of this Response
.
pub fn into_body(self) -> Decoder
[src]
pub fn into_body(self) -> Decoder
Consumes the response, returning the body
pub fn body(&self) -> &Decoder
[src]
pub fn body(&self) -> &Decoder
Get a reference to the response body.
pub fn body_mut(&mut self) -> &mut Decoder
[src]
pub fn body_mut(&mut self) -> &mut Decoder
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]
pub fn version(&self) -> Version
Get the HTTP Version
of this Response
.
pub fn json<T: DeserializeOwned>(&mut self) -> Json<T>
[src]
pub fn json<T: DeserializeOwned>(&mut self) -> Json<T>
Try to deserialize the response body as JSON using serde
.
pub fn error_for_status(self) -> Result<Self>
[src]
pub fn error_for_status(self) -> Result<Self>
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) ); } } }