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 authored and GitHub committed 2018-09-05 16:47:14 -07:00
1 parent 1961f2ef54
commit fd1b8491db
9 files changed
+82 -17

No files matched your search

+4
View File
@@ -20,6 +20,8 @@ import (
"bytes"
"encoding/json"
"errors"
"io"
"io/ioutil"
"net/http"
)
@@ -54,6 +56,8 @@ func (h *HTTPTarget) startHTTPLogger() {
continue
}
if resp.Body != nil {
buf := make([]byte, 512)
io.CopyBuffer(ioutil.Discard, resp.Body, buf)
resp.Body.Close()
}
}