Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How does Go handle DNS requests when using a HTTP proxy?

When you configure a http.Client in Go with a HTTP proxy, how does Go handle the DNS request?

I suspect that the name resolved is locally, then the request is proxied.

Is that correct? Or is the DNS request also somehow proxied through?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

    proxiedClient := &http.Client{
        Transport: &http.Transport{
            Proxy: http.ProxyURL(proxyURL),
        },
    }

>Solution :

DNS is done locally, unless a DNS library is used within the code to explicitly do the DNS queries in a non-local behavior.

Once the hostname is resolved by DNS (usually locally), then http.Client can be used to proxy the actual HTTP/S request

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading