Skip to content

Commit 4665dff

Browse files
committed
api: disable http.Transport.ForceAttemptHTTP2 by default
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
1 parent 31275f2 commit 4665dff

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

vim25/soap/client.go

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,20 +135,31 @@ func ParseURL(s string) (*url.URL, error) {
135135
return u, nil
136136
}
137137

138+
// Go's ForceAttemptHTTP2 default is true, we disable by default.
139+
// This undocumented env var can be used to enable.
140+
var http2 = os.Getenv("GOVMOMI_HTTP2") == "true"
141+
138142
func NewClient(u *url.URL, insecure bool) *Client {
139143
var t *http.Transport
140144

141145
if d, ok := http.DefaultTransport.(*http.Transport); ok {
142-
t = d.Clone()
146+
// Inherit the same defaults explicitly set in http.DefaultTransport,
147+
// unless otherwise noted.
148+
t = &http.Transport{
149+
Proxy: d.Proxy,
150+
DialContext: d.DialContext,
151+
ForceAttemptHTTP2: http2, // false by default in govmomi
152+
MaxIdleConns: d.MaxIdleConns,
153+
IdleConnTimeout: d.IdleConnTimeout,
154+
TLSHandshakeTimeout: d.TLSHandshakeTimeout,
155+
ExpectContinueTimeout: d.ExpectContinueTimeout,
156+
}
143157
} else {
144158
t = new(http.Transport)
145159
}
146160

147-
if insecure {
148-
if t.TLSClientConfig == nil {
149-
t.TLSClientConfig = new(tls.Config)
150-
}
151-
t.TLSClientConfig.InsecureSkipVerify = insecure
161+
t.TLSClientConfig = &tls.Config{
162+
InsecureSkipVerify: insecure,
152163
}
153164

154165
c := newClientWithTransport(u, insecure, t)

0 commit comments

Comments
 (0)