httpie / cli

🥧 HTTPie CLI — modern, user-friendly command-line HTTP client for the API era. JSON support, colors, sessions, downloads, plugins & more.
https://httpie.io
BSD 3-Clause "New" or "Revised" License
33.93k stars 3.68k forks source link

Add -4 and -6 switches to force IP protocol version #94

Open ThiefMaster opened 12 years ago

ThiefMaster commented 12 years ago

Would be useful in some cases, e.g. when a host serves different responses depending on the IP version.

-4and -6 are pretty common for this anyway.

berkant commented 4 years ago

No updates since 8 years?

Almad commented 3 years ago

We'd love to fix this, but when looking into it, we see it still blocked in the underlying libraries. We'll keep looking for solutions, but we can't promise any timeline since we don't see any easy fix.

Help or pointers very welcome!

dwt commented 3 years ago

@Almad could you give some pointers on this bug what kind of blockers you see, so whoever is interested in helping here doesn't have to dig out that information again? Thanks!

Almad commented 3 years ago

Ah, apologies, somehow thought it's linked here— https://github.com/psf/requests/issues/1691

markstos commented 6 months ago

For http (not https), there's a workaround in that you can give the hostname as an IPv6 IP address, and pass the host name as Host:example.com (with your real target domain).

https --print=Hh https://[YOUR-IPv6-ADDR-IN-BRACKETS]/ Host:example.com

It doesn't work for HTTPS because the SSL certificate is assigned to a host name that doesn't match the IP you are connecting to.

It looks like to really fix this, a different upstream library would needed, as it seems the current one is not going to support this (or can't).

Ousret commented 6 months ago

This is most likely fixed by https://github.com/httpie/cli/pull/1531 If the project owner agrees to merge it.

Meanwhile, you may try it (the patch) yourself.

pip install "git+https://github.com/Ousret/HTTPie.git@feature-tryout-niquests" -U

And do https -4 https://pie.dev/get or https -6 https://pie.dev/get

markstos commented 6 months ago

@Ousret I tested that fork and found that the -4 and -6 flags both worked as expected. Thank you.

I installed privately with pipx to not conflict with a global version.