diff --git a/src/client/legacy/client.rs b/src/client/legacy/client.rs index 668d699..5441c78 100644 --- a/src/client/legacy/client.rs +++ b/src/client/legacy/client.rs @@ -87,7 +87,11 @@ macro_rules! e { type PoolKey = (http::uri::Scheme, http::uri::Authority); enum TrySendError { - Retryable { error: Error, req: Request }, + Retryable { + error: Error, + req: Request, + connection_reused: bool, + }, Nope(Error), } @@ -239,8 +243,12 @@ where req = match self.try_send_request(req, pool_key.clone()).await { Ok(resp) => return Ok(resp), Err(TrySendError::Nope(err)) => return Err(err), - Err(TrySendError::Retryable { mut req, error }) => { - if !self.config.retry_canceled_requests { + Err(TrySendError::Retryable { + mut req, + error, + connection_reused, + }) => { + if !self.config.retry_canceled_requests || !connection_reused { // if client disabled, don't retry // a fresh connection means we definitely can't retry return Err(error); @@ -306,7 +314,9 @@ where Err(mut err) => { return if let Some(req) = err.take_message() { Err(TrySendError::Retryable { - error: e!(Canceled, err.into_error()), + connection_reused: pooled.is_reused(), + error: e!(Canceled, err.into_error()) + .with_connect_info(pooled.conn_info.clone()), req, }) } else { @@ -314,8 +324,6 @@ where } } }; - //.send_request_retryable(req) - //.map_err(ClientError::map_with_reused(pooled.is_reused())); // If the Connector included 'extra' info, add to Response... if let Some(extra) = &pooled.conn_info.extra { @@ -744,25 +752,6 @@ impl PoolClient { PoolTx::Http2(ref mut tx) => tx.try_send_request(req), }; } - /* - //TODO: can we re-introduce this somehow? Or must people use tower::retry? - fn send_request_retryable( - &mut self, - req: Request, - ) -> impl Future, (Error, Option>)>> - where - B: Send, - { - match self.tx { - #[cfg(not(feature = "http2"))] - PoolTx::Http1(ref mut tx) => tx.send_request_retryable(req), - #[cfg(feature = "http1")] - PoolTx::Http1(ref mut tx) => Either::Left(tx.send_request_retryable(req)), - #[cfg(feature = "http2")] - PoolTx::Http2(ref mut tx) => Either::Right(tx.send_request_retryable(req)), - } - } - */ } impl pool::Poolable for PoolClient