Skip to content

Commit

Permalink
Remove the need to clone parts
Browse files Browse the repository at this point in the history
Instead of using `response.body()` we can basically inline it so that
response isn't consumed.
  • Loading branch information
Nick Spain committed Sep 16, 2024
1 parent cc72a26 commit 22250b8
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -518,7 +517,7 @@ impl Client {
}

let response = BytesResponse {
parts,
parts: response.parts,
body: Box::new(StaticBody { bytes: body }),
};
return Ok(response);
Expand Down

0 comments on commit 22250b8

Please sign in to comment.