Skip to content

Commit 6ca6da4

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 00d52e4 commit 6ca6da4

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
@@ -281,18 +281,15 @@ where
281281
authority_form(req.uri_mut());
282282
}
283283

284-
let fut = pooled
284+
let mut res = pooled
285285
.send_request_retryable(req)
286-
.map_err(ClientError::map_with_reused(pooled.is_reused()));
286+
.await
287+
.map_err(ClientError::map_with_reused(pooled.is_reused()))?;
287288

288289
// If the Connector included 'extra' info, add to Response...
289-
let extra_info = pooled.conn_info.extra.clone();
290-
let fut = fut.map_ok(move |mut res| {
291-
if let Some(extra) = extra_info {
292-
extra.set(res.extensions_mut());
293-
}
294-
res
295-
});
290+
if let Some(extra) = &pooled.conn_info.extra {
291+
extra.set(res.extensions_mut());
292+
}
296293

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

308-
let mut res = fut.await?;
309-
310305
// If pooled is HTTP/2, we can toss this reference immediately.
311306
//
312307
// when pooled is dropped, it will try to insert back into the

0 commit comments

Comments
 (0)