Open BobbyMcWho opened 4 years ago
@BobbyMcWho sounds useful and I don't think this is currently available in Faraday.
I checked the PRs history and I found a similar addition done for reason_phrase
: https://github.com/lostisland/faraday/pull/547.
I'm not a huge fan of the implementation, but I doubt there's an easier/better way to implement this, so it could be used as a reference for implementing this as well.
Just a list of "requirements":
Options
definition, as the order of fields does matter)@iMacTia how do you feel about peer_ip
?
@BobbyMcWho that would work, I was thinking also of resolved_ip
or some other reference to DNS, but as I mentioned I don't feel too strongly as far as it's a recognised technical term
Yeah I started digging into this last night and there doesn't seem to be broad support for it in the http libraries, even Net::Http is a bit more of a challenge than I expected. I'll have to do some more digging when I have some time
I know this request is a bit stale, but knowing the host ip address would be super useful for us, to trace connections.
NET::HTTP
provides ipaddr
which will return the underlying sockets peer address as already mentioned
https://ruby-doc.org/stdlib-3.0.0/libdoc/net/http/rdoc/Net/HTTP.html#method-i-ipaddr
I unfortunately don't have time to work on this, so if you want to pick up the mantle, I'm sure others will want it later as well 😅
I've done some fairly comprehensive digging into the source code of this gem, typhoeus, and net::http, and I believe this should be something we can implement.
I would like to be able to access the resolved IP of the request on the response body, Net::HTTP I believe exposes this via #ipaddr, and Typhoeus via Response::Informations#primary_ip.
I believe this would involve adding the method to the
Faraday::Response
class similar to body, adding an ip attr to the Env class, and in each adapter changing the save_response call to also add the ip info to the env.