masterzen/winrm

Need a way to set Proxy in Transporter

SwampDragons opened this issue · 2 comments

Hi, I maintain Packer and we use your library for our winrm communications. We recently discovered that we cannot set the NO_PROXY environment variable during our build and have it picked up by your transporter, because the way ProxyFromEnvironment works here, https://github.com/masterzen/winrm/blob/master/http.go#L57, it's instantiated the very first time Packer makes a request using the net/http library, which is before we know the IP address of the instance we want to add to NO_PROXY.

I can probably copy the majority of the http.go file and tweak it from within Packer and feed it in via decorators, but it would cause many fewer headaches if we could add a proxy function directly to clientRequest, the way you currently handle the "Dial" option.

I have a working diff here and I'm happy to open a PR if it's something you're willing to add.

Hi @SwampDragons ,

I understand your issue.
Please send me a PR, I'll merge it ASAP.

Thanks !

Great, I'll do that now.