Skip to content

Commit 1ec1db2

Browse files
committed
chore(client): refactor the response handling in Client::send_request
No need to map futures as we already await in that method anyway.
1 parent f1b89c1 commit 1ec1db2

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/client/client.rs

+7-12
Original file line numberDiff line numberDiff line change
@@ -272,18 +272,15 @@ where
272272
authority_form(req.uri_mut());
273273
}
274274

275-
let fut = pooled
275+
let mut res = pooled
276276
.send_request_retryable(req)
277-
.map_err(ClientError::map_with_reused(pooled.is_reused()));
277+
.await
278+
.map_err(ClientError::map_with_reused(pooled.is_reused()))?;
278279

279280
// If the Connector included 'extra' info, add to Response...
280-
let extra_info = pooled.conn_info.extra.clone();
281-
let fut = fut.map_ok(move |mut res| {
282-
if let Some(extra) = extra_info {
283-
extra.set(res.extensions_mut());
284-
}
285-
res
286-
});
281+
if let Some(extra) = &pooled.conn_info.extra {
282+
extra.set(res.extensions_mut());
283+
}
287284

288285
// As of [email protected], there is a race condition in the mpsc
289286
// channel, such that sending when the receiver is closing can
@@ -293,11 +290,9 @@ where
293290
// To counteract this, we must check if our senders 'want' channel
294291
// has been closed after having tried to send. If so, error out...
295292
if pooled.is_closed() {
296-
return fut.await;
293+
return Ok(res);
297294
}
298295

299-
let mut res = fut.await?;
300-
301296
// If pooled is HTTP/2, we can toss this reference immediately.
302297
//
303298
// when pooled is dropped, it will try to insert back into the

0 commit comments

Comments
 (0)