goproxy
goproxy copied to clipboard
Proxy-Authorization isn't set for CONNECT requests
I have a proxy set up with proxy.ConnectDial = proxy.NewConnectDialToProxy(externalProxy)
. externalProxy
has a username and password like this: https://username:[email protected]
. This doesn't work because the username and password are ignored when the CONNECT request is made.
I'm working around this by doing this:
u, err := url.Parse(externalProxy)
proxy.ConnectDial = proxy.NewConnectDialToProxyWithHandler(externalProxy, func(req *http.Request) {
if u.User != nil {
credentials := base64.StdEncoding.EncodeToString([]byte(u.User.String()))
req.Header.Add("Proxy-Authorization", "Basic "+credentials)
}
})
@moonchen any progress on this? did you make it work?