pub trait ResponseExt: Sealed {
// Required method
fn error_for_status_with_body(
self,
) -> impl Future<Output = Result<Response, ErrorWithBody>> + Send + Sync + 'static;
}Expand description
Extension trait for reqwest::Response to provide additional
functionality.
Required Methods§
Sourcefn error_for_status_with_body(
self,
) -> impl Future<Output = Result<Response, ErrorWithBody>> + Send + Sync + 'static
fn error_for_status_with_body( self, ) -> impl Future<Output = Result<Response, ErrorWithBody>> + Send + Sync + 'static
Like reqwest::Response::error_for_status, but if the response is an
error, also reads and includes the response body in the returned
error.
§Example
use reqwest_extra::ResponseExt;
let response = reqwest::get("https://api.github.com/user").await.unwrap();
let err = response.error_for_status_with_body().await.unwrap_err();
println!("{err}");Output (line-wrapped for readability):
HTTP status client error (403 Forbidden) for url (https://api.github.com/user),
body: b"\r\nRequest forbidden by administrative rules.
Please make sure your request has a User-Agent header
(https://docs.github.com/en/rest/overview/resources-in-the-rest-api#user-agent-required).
Check https://developer.github.com for other possible causes.\r\n"Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.