Skip to content
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

Suggestion: add Response::remote_addr() method #488

Closed
mvforell opened this issue Mar 4, 2022 · 2 comments · Fixed by #489
Closed

Suggestion: add Response::remote_addr() method #488

mvforell opened this issue Mar 4, 2022 · 2 comments · Fixed by #489

Comments

@mvforell
Copy link
Contributor

mvforell commented Mar 4, 2022

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?

@mvforell
Copy link
Contributor Author

mvforell commented Mar 4, 2022

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.

@algesten
Copy link
Owner

algesten commented Mar 5, 2022

An IP address is quite small. I'd be fine with adding that to response.

Happy to accept a PR for this.

jsha pushed a commit that referenced this issue Oct 3, 2022
@jsha jsha closed this as completed in #489 Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants