dongzheng3113 2017-05-31 17:27
浏览 406

在Golang中绕过http_proxy

I have env variable set for http_proxy, but with another call, I like to bypass proxy and use direct connection to destination server instead.

Is there any way I can do that in Go lang?

Thanks.

  • 写回答

2条回答 默认 最新

  • dpgbh20688 2017-05-31 17:53
    关注

    As @Volker mentioned, you can either:

    • Use your own RoundTripper instead of the DefaultTransport
    • Modify DefaultTransport.Proxy to return nil for the request in question
    • If the call you want to ignore proxies with is to a specific host, and you always want to ignore proxy for calls to that host, add the host to the NO_PROXY environment variable
    评论

报告相同问题?