Closed
Description
net/http.Transport currently has:
https://golang.org/pkg/net/http/#Transport.ProxyConnectHeader
// ProxyConnectHeader optionally specifies headers to send to
// proxies during CONNECT requests.
ProxyConnectHeader Header // Go 1.8
... but it's static for the life of the Transport.
Some authentication modes like NTLM/Kerberos/Negotiate require a dynamic header value, which currently requires making a new Transport for each request going through a proxy. That's heavy, as the Transport is the unit of connection reuse.
Proposal:
// GetProxyConnectHeader is called to return headers to send to
// proxuURL during a CONNECT request to the target ip:port. If it returns an error, the Transport
// RoundTrip fails with that error. It can return (nil, nil) to not add headers.
// If GetProxyConnectHeader is non-nil, ProxyConnectHeader is ignored.
GetProxyConnectHeader func(ctx context.Context, proxyURL *url.URL, target string) (Header, error)
// ProxyConnectHeader optionally specifies headers to send to
// proxies during CONNECT requests. For dynamic use, see GetProxyConnectHeader.
ProxyConnectHeader Header // Go 1.8