Skip to content

Commit

Permalink
api: disable http.Transport.ForceAttemptHTTP2 by default
Browse files Browse the repository at this point in the history
Revert soap.Client http.Transport back to manual construction, rather than Clone() (see 313aa85)

Disable ForceAttemptHTTP2 by default, as we currently see degraded transfer rates with large file uploads.

Closes #3564
  • Loading branch information
dougm committed Oct 1, 2024
1 parent 31275f2 commit 4665dff
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 4665dff

Please # to comment.