Make execute method on WASM client for compatibility with async_impl (#989)

The async_impl of reqwest has a `execute` impl on Client which is used
to execute a request and return a Result Future. When converting a crate
from async to wasm this method is missing, requiring forking and
rewriting the crate. By introducing this method less errors will be
introduced when trying to compile to wasm
This commit is contained in:
Jason van den Hurk
2020-08-06 19:37:05 +02:00
committed by GitHub
parent edc9e244cb
commit 77d7e452e1

View File

@@ -92,6 +92,25 @@ impl Client {
RequestBuilder::new(self.clone(), req)
}
/// Executes a `Request`.
///
/// A `Request` can be built manually with `Request::new()` or obtained
/// from a RequestBuilder with `RequestBuilder::build()`.
///
/// You should prefer to use the `RequestBuilder` and
/// `RequestBuilder::send()`.
///
/// # Errors
///
/// This method fails if there was an error while sending request,
/// redirect loop was detected or redirect limit was exhausted.
pub fn execute(
&self,
request: Request,
) -> impl Future<Output = Result<Response, crate::Error>> {
self.execute_request(request)
}
pub(super) fn execute_request(
&self,
req: Request,