-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get socket parameters in Client or Server #1402
Comments
I agree there are cases where this is desirable, but there are also reasons it doesn't exist yet. These are properties specific to TCP, whereas hyper (and HTTP even) don't require the underlying transport to be TCP (Unix domain sockets don't have a concept of addresses, for example). It'd probably need some sort of middleware between when a transport is chosen ready to use and when a |
When would one expect to be able to receive this information? You generally give a If we went that way, I'd think that instead of exposing exactly that the type is in A possible API: pub struct ConnectionInfo {
local_addr: Option<SocketAddr>,
remote_addr: Option<SocketAddr>,
// maybe new fields in the future
}
impl ConnectionInfo {
pub fn get(res: &Response) -> ConnectionInfo {
// fetch an internal type from `extensions()`,
// fill in whatever info was possible
}
pub fn set(&self, res: &mut Response) {
}
} |
Sometimes you want to write logs and include the remote host in the log. |
Yes, of course. I was asking at what point would it be expected to access the remote info? Is it fine as a property of the response? |
I guess you could also want it even earlier than that: you establish a TCP connection, log the remote host and then SSL auth fails. |
- Adds `client::Builder::set_conn_info` to opt-in to having connection info added to `Response`s from clients. - Adds `ext::ConnectionInfo` that allows querying types (like a `Response`) for connection info. Closes #1402
- 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
- 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
- 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
- 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
- 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
- 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
When a
Client
makes a request, it may connect to one of many hosts associated with the URL.I would like to have a way to access the IP address associated with the remote host. This is accessible from tokio via
NetSocket::peer_addr()
.Logically, one should also be able to access the local address with
local_addr()
, and so it makes sense to support access to many of the apis made available on the socket-level from tokio.The text was updated successfully, but these errors were encountered: