ureq
ureq copied to clipboard
Suggestion: add `Response::remote_addr()` method
It would be great if ureq::Response
had a remote_addr()
method that returns an Option<SocketAddr>
describing the remote address that the response came from.
E.g. reqwest
's Response
type already has such a method.
What do you think about this?
I've taken a glance at the code for ureq::Response
, and getting the remote address could be achieved by adding this line:
let remote_addr = stream.socket().and_then(|s| s.peer_addr().ok());
at the start of Response::do_from_stream()
and storing that in a new member of Response
(and adding a getter for that, of course).
But I'm not sure if that's acceptable for you, as this means an increased size for Response
.
An IP address is quite small. I'd be fine with adding that to response.
Happy to accept a PR for this.