Httpie: Add equivalent cURL --resolve flag

Created on 27 Oct 2012  ·  13Comments  ·  Source: httpie/httpie

Per cURL --help:

--resolve HOST:PORT:ADDRESS Force resolve of HOST:PORT to ADDRESS

(bypasses hosts file)

example usage:

http --resolve "www.foo.com:127.0.0.1" GET www.foo.com/whatever

OR

http --resolve "www.foo.com:8080:127.0.0.1" GET www.foo.com:8080/whatever

feature

Most helpful comment

The above trick doesn't work for HTTPS sites. We need a full resolve option similar to curl.

All 13 comments

I think you can achieve the same thing by explicitly setting the Host header:

http 127.0.0.1/whatever Host:www.foo.com

The above trick doesn't work for HTTPS sites. We need a full resolve option similar to curl.

I'm using httpie to test that I setup my DNS round-robin correctly. +1 for feature

Just curious... This has been open for over a year now (since it was reopened)... any chance it's getting looked at? Seems like a useful feature to have.

The underlying software that HTTPie uses does not allow people to specify their own IP addresses for a specific host. It's unlikely it will be added there. So, @aztlan2k it's not likely this is being worked on. Sorry. :/

Hi! I've submitted some code and would appreciate any comments.

Just re-submitted via another PR. Would you mind to check?

Any chance of getting this merged? @jakubroztocil

That would be great to prepare site migration and avoid problems!

This can be achieved via dig +short <host> A. It's a DNS thing, not really HTTP

dig is used to query the DNS, the proposed --resove is used to force resolution of an address during an HTTP fetch (probably to a value the DNS server doesn't yet have but will have in the future, after this testing is done).
It's rather an alternative to editing /etc/hosts than it is to using dig (or drill, or similar).

In case anybody is confused as to why this is needed "for HTTPS", it's specifically when TLS SNI (Server Name Indication) is used in place of the HTTP Host header to disambiguate connections (e.g. hostname-based L7 routing in reverse-proxies, or "virtual server" use-cases in general), which is extremely common.

In that context, resolving the IP beforehand isn't sufficient as it won't constitute a virtual server name expected by the actual server.

If an equivalent to --resolve isn't desirable for any reason, forcing the SNI value (e.g. --sni) would be an acceptable alternative IMO since we can already do the equivalent for plain HTTP (i.e. set the Host header value explicitly).

This can also be useful for absolute redirects (That include a full URL with a host name)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eliangcs picture eliangcs  ·  5Comments

Abdallah-Obaid picture Abdallah-Obaid  ·  4Comments

cunde picture cunde  ·  7Comments

rashthedude picture rashthedude  ·  3Comments

a-x- picture a-x-  ·  7Comments