From e2635c9f8ddb7d06320d00eda6e8b3e62f2b44bc Mon Sep 17 00:00:00 2001 From: tl-rodrigo-gryzinski <73602926+tl-rodrigo-gryzinski@users.noreply.github.com> Date: Thu, 21 Jul 2022 16:39:15 +0100 Subject: [PATCH] Add note about streaming requests in RetryTransientMiddleware docs (#51) --- reqwest-retry/src/middleware.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/reqwest-retry/src/middleware.rs b/reqwest-retry/src/middleware.rs index 51195e0..f701b12 100644 --- a/reqwest-retry/src/middleware.rs +++ b/reqwest-retry/src/middleware.rs @@ -35,6 +35,18 @@ static MAXIMUM_NUMBER_OF_RETRIES: u32 = 10; /// let client = ClientBuilder::new(Client::new()).with(retry_transient_middleware).build(); ///``` /// +/// # Note +/// +/// This middleware always errors when given requests with streaming bodies, before even executing +/// the request. When this happens you'll get an [`Error::Middleware`] with the message +/// 'Request object is not clonable. Are you passing a streaming body?'. +/// +/// Some workaround suggestions: +/// * If you can fit the data in memory, you can instead build static request bodies e.g. with +/// `Body`'s `From` or `From` implementations. +/// * You can wrap this middleware in a custom one which skips retries for streaming requests. +/// * You can write a custom retry middleware that builds new streaming requests from the data +/// source directly, avoiding the issue of streaming requests not being clonable. pub struct RetryTransientMiddleware { retry_policy: T, }