Skip to content

Commit

Permalink
Merge pull request #3249 from dougm/disable-esx-keep-alive
Browse files Browse the repository at this point in the history
api: disable HTTP Keep-Alive for direct ESX connections
  • Loading branch information
dougm authored Sep 28, 2023
2 parents 20719b2 + a91eb5e commit 3741df6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions guest/toolbox/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ func (c *Client) Download(ctx context.Context, src string) (io.ReadCloser, int64
}

p := soap.DefaultDownload
p.Close = true // disable Keep-Alive connection to ESX

if internal.UsingEnvoySidecar(c.ProcessManager.Client()) {
vc = internal.ClientWithEnvoyHostGateway(vc)
Expand Down Expand Up @@ -346,6 +347,8 @@ func (c *Client) Upload(ctx context.Context, src io.Reader, dst string, p soap.U
return err
}

p.Close = true // disable Keep-Alive connection to ESX

if internal.UsingEnvoySidecar(c.ProcessManager.Client()) {
vc = internal.ClientWithEnvoyHostGateway(vc)
}
Expand Down
10 changes: 8 additions & 2 deletions object/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,10 @@ func (d Datastore) uploadTicket(ctx context.Context, path string, param *soap.Up
return nil, nil, err
}

p.Ticket = ticket
if ticket != nil {
p.Ticket = ticket
p.Close = true // disable Keep-Alive connection to ESX
}

return u, &p, nil
}
Expand All @@ -294,7 +297,10 @@ func (d Datastore) downloadTicket(ctx context.Context, path string, param *soap.
return nil, nil, err
}

p.Ticket = ticket
if ticket != nil {
p.Ticket = ticket
p.Close = true // disable Keep-Alive connection to ESX
}

return u, &p, nil
}
Expand Down
5 changes: 4 additions & 1 deletion vim25/soap/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ type Upload struct {
Headers map[string]string
Ticket *http.Cookie
Progress progress.Sinker
Close bool
}

var DefaultUpload = Upload{
Expand Down Expand Up @@ -754,7 +755,7 @@ func (c *Client) Upload(ctx context.Context, f io.Reader, u *url.URL, param *Upl
}

req = req.WithContext(ctx)

req.Close = param.Close
req.ContentLength = param.ContentLength
req.Header.Set("Content-Type", param.Type)

Expand Down Expand Up @@ -812,6 +813,7 @@ type Download struct {
Ticket *http.Cookie
Progress progress.Sinker
Writer io.Writer
Close bool
}

var DefaultDownload = Download{
Expand All @@ -826,6 +828,7 @@ func (c *Client) DownloadRequest(ctx context.Context, u *url.URL, param *Downloa
}

req = req.WithContext(ctx)
req.Close = param.Close

for k, v := range param.Headers {
req.Header.Add(k, v)
Expand Down

0 comments on commit 3741df6

Please sign in to comment.