feat(client): add HttpInfo::local_addr() method
This adds `local_addr` information from `TcpStream` to the `HttpInfo` struct Closes #2767
This commit is contained in:
@@ -66,6 +66,7 @@ pub struct HttpConnector<R = GaiResolver> {
|
|||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct HttpInfo {
|
pub struct HttpInfo {
|
||||||
remote_addr: SocketAddr,
|
remote_addr: SocketAddr,
|
||||||
|
local_addr: SocketAddr,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@@ -360,8 +361,8 @@ where
|
|||||||
impl Connection for TcpStream {
|
impl Connection for TcpStream {
|
||||||
fn connected(&self) -> Connected {
|
fn connected(&self) -> Connected {
|
||||||
let connected = Connected::new();
|
let connected = Connected::new();
|
||||||
if let Ok(remote_addr) = self.peer_addr() {
|
if let (Ok(remote_addr), Ok(local_addr)) = (self.peer_addr(), self.local_addr()) {
|
||||||
connected.extra(HttpInfo { remote_addr })
|
connected.extra(HttpInfo { remote_addr, local_addr })
|
||||||
} else {
|
} else {
|
||||||
connected
|
connected
|
||||||
}
|
}
|
||||||
@@ -373,6 +374,11 @@ impl HttpInfo {
|
|||||||
pub fn remote_addr(&self) -> SocketAddr {
|
pub fn remote_addr(&self) -> SocketAddr {
|
||||||
self.remote_addr
|
self.remote_addr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get the local address of the transport used.
|
||||||
|
pub fn local_addr(&self) -> SocketAddr {
|
||||||
|
self.local_addr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pin_project! {
|
pin_project! {
|
||||||
|
|||||||
Reference in New Issue
Block a user