On 14/4/21 6:39 am, Orson Cart wrote:
So, to clarify:

1/ I have a proxy (Fiddler) running locally on port 8888
2/ my /etc/hosts file has an entry as follows: 127.0.0.1 fiddler
3/ My HTTP_PROXY and HTTPS_PROXY environment variables are set to http://fiddler:8888 <http://localhost:8888/> and https://fiddler:8888 <http://localhost:8888/> respectively

if I then issue a request via curl then that request is picked up by the proxy. However if I make the same request from my go application, the request appears to bypass the proxy and is sent directly. I'm perplexed.

The "Name Resolution" section in https://golang.org/pkg/net/ says:

On Unix systems, the resolver has two options for resolving names. It can use a pure Go resolver that sends DNS requests directly to the servers listed in /etc/resolv.conf, or it can use a cgo-based resolver that calls C library routines such as getaddrinfo and getnameinfo.

By default the pure Go resolver is used, because a blocked DNS request consumes only a goroutine, while a blocked C call consumes an operating system thread.

That might have some bearing on your problem. To see if it's the case, as the page suggests:

export GODEBUG=netdns=cgo   # force cgo resolver


Best Regards,
Adrian

--
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/2709afa1-a037-8d3c-3fe0-f469588e3c8e%4003s.net.

Reply via email to