From 22250b8e0daadd6cde23096aa6f1f0e174e11165 Mon Sep 17 00:00:00 2001 From: Nick Spain Date: Mon, 16 Sep 2024 15:03:35 +1000 Subject: [PATCH] Remove the need to clone `parts` Instead of using `response.body()` we can basically inline it so that response isn't consumed. --- src/lib.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 33375b7..f55d4c2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -500,10 +500,9 @@ impl Client { let mut nonce = nonce; loop { - let response = self.inner_post(payload, nonce.clone(), signer, url).await?; + let mut response = self.inner_post(payload, nonce.clone(), signer, url).await?; if response.parts.status == StatusCode::BAD_REQUEST { - let parts = response.parts.clone(); - let body = response.body().await.map_err(Error::Other)?; + let body = response.body.into_bytes().await.map_err(Error::Other)?; let problem: Problem = serde_json::from_slice(&body)?; if problem .r#type @@ -518,7 +517,7 @@ impl Client { } let response = BytesResponse { - parts, + parts: response.parts, body: Box::new(StaticBody { bytes: body }), }; return Ok(response);