Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: disable http.Transport.ForceAttemptHTTP2 by default #3566

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions vim25/soap/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,31 @@ func ParseURL(s string) (*url.URL, error) {
return u, nil
}

// Go's ForceAttemptHTTP2 default is true, we disable by default.
// This undocumented env var can be used to enable.
var http2 = os.Getenv("GOVMOMI_HTTP2") == "true"

func NewClient(u *url.URL, insecure bool) *Client {
var t *http.Transport

if d, ok := http.DefaultTransport.(*http.Transport); ok {
t = d.Clone()
// Inherit the same defaults explicitly set in http.DefaultTransport,
mayankbh marked this conversation as resolved.
Show resolved Hide resolved
// unless otherwise noted.
t = &http.Transport{
Proxy: d.Proxy,
DialContext: d.DialContext,
ForceAttemptHTTP2: http2, // false by default in govmomi
MaxIdleConns: d.MaxIdleConns,
IdleConnTimeout: d.IdleConnTimeout,
TLSHandshakeTimeout: d.TLSHandshakeTimeout,
ExpectContinueTimeout: d.ExpectContinueTimeout,
}
} else {
t = new(http.Transport)
}

if insecure {
if t.TLSClientConfig == nil {
t.TLSClientConfig = new(tls.Config)
}
t.TLSClientConfig.InsecureSkipVerify = insecure
t.TLSClientConfig = &tls.Config{
InsecureSkipVerify: insecure,
}

c := newClientWithTransport(u, insecure, t)
Expand Down
Loading