seanmonstar / reqwest

An easy and powerful Rust HTTP Client
https://docs.rs/reqwest
Apache License 2.0
9.7k stars 1.09k forks source link

Can reqwest support Dns self parse? #1059

Open flyinmind opened 3 years ago

flyinmind commented 3 years ago

OkHttp or ApacheHttpClient in java can support a Dns resolver customized. In actix-web-client, can set address in ClientRequest to realize the feature. It is useful specially in micro-service or client-based-balance. Can reqwest support a Dns resolver or other function to realize it? Thanks a lot!

stevelr commented 3 years ago

IMHO, this functionality is better kept outside reqwest, since there are so many different ways to do DNS resolution.

However, you could write a fairly simple wrapper to do what you want:

parse the url with url::Url, extract the host, dns lookup host using your favorite dns client library, set url host to IP, use url.to_string() to create reqwest.Request, and add a Host header with the original hostname

stevelr commented 3 years ago

looks like dup of #1007

flyinmind commented 3 years ago

Yes, they are same. Is there a way?