-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client): include connection info in Client::send_request errors (…
- Loading branch information
Showing
2 changed files
with
37 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -251,7 +251,7 @@ where | |
if req.version() == Version::HTTP_2 { | ||
warn!("Connection is HTTP/1, but request requires HTTP/2"); | ||
return Err(ClientError::Normal( | ||
crate::Error::new_user_unsupported_version(), | ||
crate::Error::new_user_unsupported_version().with_client_connect_info(pooled.conn_info.clone()), | ||
)); | ||
} | ||
|
||
|
@@ -281,18 +281,20 @@ where | |
authority_form(req.uri_mut()); | ||
} | ||
|
||
let fut = pooled | ||
.send_request_retryable(req) | ||
.map_err(ClientError::map_with_reused(pooled.is_reused())); | ||
let mut res = match pooled.send_request_retryable(req).await { | ||
Err((err, orig_req)) => { | ||
return Err(ClientError::map_with_reused(pooled.is_reused())(( | ||
err.with_client_connect_info(pooled.conn_info.clone()), | ||
orig_req, | ||
))); | ||
} | ||
Ok(res) => res, | ||
}; | ||
|
||
// If the Connector included 'extra' info, add to Response... | ||
let extra_info = pooled.conn_info.extra.clone(); | ||
let fut = fut.map_ok(move |mut res| { | ||
if let Some(extra) = extra_info { | ||
extra.set(res.extensions_mut()); | ||
} | ||
res | ||
}); | ||
if let Some(extra) = &pooled.conn_info.extra { | ||
extra.set(res.extensions_mut()); | ||
} | ||
|
||
// As of [email protected], there is a race condition in the mpsc | ||
// channel, such that sending when the receiver is closing can | ||
|
@@ -302,11 +304,9 @@ where | |
// To counteract this, we must check if our senders 'want' channel | ||
// has been closed after having tried to send. If so, error out... | ||
if pooled.is_closed() { | ||
return fut.await; | ||
return Ok(res); | ||
} | ||
|
||
let mut res = fut.await?; | ||
|
||
// If pooled is HTTP/2, we can toss this reference immediately. | ||
// | ||
// when pooled is dropped, it will try to insert back into the | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters