goproxy icon indicating copy to clipboard operation
goproxy copied to clipboard

Proxy-Authorization isn't set for CONNECT requests

Open moonchen opened this issue 3 years ago • 1 comments

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 avatar Apr 16 '21 00:04 moonchen

@moonchen any progress on this? did you make it work?

ciokan avatar Dec 17 '21 23:12 ciokan