Drain response body properly for http connection pool (#6415)

Currently Go http connection pool was not being properly
utilized leading to degrading performance as the number
of concurrent requests increased.

As recommended by Go implementation, we have to drain the
response body and close it.
This commit is contained in:
Harshavardhana
2018-09-05 16:47:14 -07:00
committed by GitHub
parent 1961f2ef54
commit fd1b8491db
9 changed files with 82 additions and 17 deletions

View File

@@ -324,7 +324,7 @@ func downloadReleaseURL(releaseChecksumURL string, timeout time.Duration, mode s
if resp == nil {
return content, fmt.Errorf("No response from server to download URL %s", releaseChecksumURL)
}
defer resp.Body.Close()
defer CloseResponse(resp.Body)
if resp.StatusCode != http.StatusOK {
return content, fmt.Errorf("Error downloading URL %s. Response: %v", releaseChecksumURL, resp.Status)
@@ -471,7 +471,7 @@ func doUpdate(sha256Hex string, latestReleaseTime time.Time, ok bool) (updateSta
if err != nil {
return updateStatusMsg, err
}
defer resp.Body.Close()
defer CloseResponse(resp.Body)
// FIXME: add support for gpg verification as well.
if err = update.Apply(resp.Body,