Open SRv6d opened 1 year ago
Hey @SRv6d, I am a newbie to Open-source, can I pick this up?
Hey @SRv6d, I am a newbie to Open-source, can I pick this up?
Of course you can, although your PR would have to be approved by a httpie maintainer (which I am not).
@turingnixstyx Any updates on this? I played around with it for a bit this morning, and it's not as easy as it looks on the surface.
All of the low level http requests are being handled by requests
which in turn uses urllib3
. Neither of these provide this information while attempting the connection (not even as debug logs we could try to capture and rewrite). I got a PoC working locally where we can access the IP of the successful connection, but it uses undocumented APIs and is not compatible across Python/requests
versions (so I don't think that's viable either).
The only robust solution would be to implement the get_connection
function in HTTPie's adapter to return a custom urllib3.ConnectionPool
which does expose this information. This would be very involved and way out of my wheelhouse. Perhaps somebody smarter could figure it out :p
@SRv6d If you're still in search of a solution, I found https://github.com/httptoolkit/httptoolkit while poking around. It's open source and would allow you to open a shell which sends all of its traffic through a local proxy capturing all the connection attempts. ⚠️ I have not used it or inspected the source code; I cannot vouch for or endorse it in any way. ⚠️ But it does look like it could do some of what you want.
@lucasconnellm Appreciate the tip, but with the lack of basic features like IP in verbose mode, HTTP/2 let alone HTTP/3, I've gone back to curl. httpx provides nicer UX but is not useful to me as a professional tool.
Somewhat partial solution would be to at least include the IP which httpie connected to (as opposed to listing all the attempted IP addresses). This should be easy enough. Threw some code into client.py (I realize this is not where the output should happen, just a POC) and this is how the output looks like:
$ python -m httpie https://storage.googleapis.com/generate_204
Connected to storage.googleapis.com (199.36.153.7) on port 443
HTTP/1.1 204 No Content
Content-Length: 0
Cross-Origin-Resource-Policy: cross-origin
Date: Sat, 30 Dec 2023 00:49:08 GMT
Checklist
Enhancement request
When running
curl
in verbose mode, it will print every ip it tries to connect to, until a connection is stablished.The above example request tells the user that
curl
was trying to connect to both2001:db8::3:8bd0
and2001:db8::3:8bd1
, while ultimately a connection was established to2001:db8::3:8bd1
.While ideally
httpie
would implement the same output ascurl
, it should at least be able to print the IP it connected to.Problem it solves
It is very common to have multiple IPv4 and IPv6 addresses within DNS and which one exactly was used is very relevant when debugging or in cases where different ip's may return different content.