mirror of
https://github.com/TrueLayer/reqwest-middleware.git
synced 2024-12-27 11:26:31 +00:00
Add note about streaming requests in RetryTransientMiddleware docs (#51)
This commit is contained in:
parent
360f23c952
commit
e2635c9f8d
1 changed files with 12 additions and 0 deletions
|
@ -35,6 +35,18 @@ static MAXIMUM_NUMBER_OF_RETRIES: u32 = 10;
|
||||||
/// let client = ClientBuilder::new(Client::new()).with(retry_transient_middleware).build();
|
/// 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<String>` or `From<Bytes>` 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<T: RetryPolicy + Send + Sync + 'static> {
|
pub struct RetryTransientMiddleware<T: RetryPolicy + Send + Sync + 'static> {
|
||||||
retry_policy: T,
|
retry_policy: T,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue