From 77d7e452e100167d8c64f8c580d359e0c60326f0 Mon Sep 17 00:00:00 2001 From: Jason van den Hurk Date: Thu, 6 Aug 2020 19:37:05 +0200 Subject: [PATCH] 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 --- src/wasm/client.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/wasm/client.rs b/src/wasm/client.rs index b7bb141..4f6ea1c 100644 --- a/src/wasm/client.rs +++ b/src/wasm/client.rs @@ -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> { + self.execute_request(request) + } + pub(super) fn execute_request( &self, req: Request,