Skip to content

Commit

Permalink
Merge pull request #3566 from dougm/disable-http2
Browse files Browse the repository at this point in the history
api: disable http.Transport.ForceAttemptHTTP2 by default
  • Loading branch information
dougm authored Oct 1, 2024
2 parents 31275f2 + 4665dff commit 40d679d
Showing 1 changed file with 17 additions and 6 deletions.
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,
// 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

0 comments on commit 40d679d

Please sign in to comment.