diff --git a/src/client/legacy/connect/http.rs b/src/client/legacy/connect/http.rs index 644f8f85..c52fb99a 100644 --- a/src/client/legacy/connect/http.rs +++ b/src/client/legacy/connect/http.rs @@ -438,12 +438,10 @@ where } } -impl Connection for TokioIo { +impl Connection for TcpStream { fn connected(&self) -> Connected { let connected = Connected::new(); - if let (Ok(remote_addr), Ok(local_addr)) = - (self.inner().peer_addr(), self.inner().local_addr()) - { + if let (Ok(remote_addr), Ok(local_addr)) = (self.peer_addr(), self.local_addr()) { connected.extra(HttpInfo { remote_addr, local_addr, @@ -454,6 +452,17 @@ impl Connection for TokioIo { } } +// Implement `Connection` for generic `TokioIo` so that external crates can +// implement their own `HttpConnector` with `TokioIo`. +impl Connection for TokioIo +where + T: Connection, +{ + fn connected(&self) -> Connected { + self.inner().connected() + } +} + impl HttpInfo { /// Get the remote address of the transport used. pub fn remote_addr(&self) -> SocketAddr {