feat(client): adds HttpInfo to responses when HttpConnector is used

- Adds `client::connect::Connected::extra()`, which allows connectors to
  specify arbitrary custom information about a connected transport.

If a connector provides this extra value, it will be set in the
`Response` extensions.

Closes #1402
This commit is contained in:
Sean McArthur
2018-10-16 13:19:48 -07:00
parent d55b5efb89
commit 13d53e1d0c
5 changed files with 145 additions and 13 deletions

View File

@@ -274,7 +274,17 @@ macro_rules! test {
let rx = rx.expect("thread panicked");
rt.block_on(res.join(rx).map(|r| r.0))
rt.block_on(res.join(rx).map(|r| r.0)).map(move |mut resp| {
// Always check that HttpConnector has set the "extra" info...
let extra = resp
.extensions_mut()
.remove::<::hyper::client::connect::HttpInfo>()
.expect("HttpConnector should set HttpInfo");
assert_eq!(extra.remote_addr(), addr, "HttpInfo should have server addr");
resp
})
});
}