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

@@ -21,7 +21,6 @@ import (
"encoding/xml"
"fmt"
"io"
"io/ioutil"
"net/http"
"strconv"
"strings"
@@ -816,11 +815,8 @@ func ossListObjectParts(client *oss.Client, bucket, object, uploadID string, par
return lupr, err
}
defer func() {
// always drain output (response body)
io.CopyN(ioutil.Discard, resp.Body, 512)
resp.Body.Close()
}()
// always drain output (response body)
defer minio.CloseResponse(resp.Body)
err = xml.NewDecoder(resp.Body).Decode(&lupr)
if err != nil {