From 5e9dae490ea4eacaa37ab0a60e4091b013137611 Mon Sep 17 00:00:00 2001 From: Eitan Katznelson Date: Mon, 1 Nov 2021 12:20:51 -0700 Subject: [PATCH] Make sure that even when response status is <300 that we fully read the response body. --- analytics.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/analytics.go b/analytics.go index fa13434..1abab31 100644 --- a/analytics.go +++ b/analytics.go @@ -311,6 +311,10 @@ func (c *client) report(res *http.Response) (err error) { if res.StatusCode < 300 { c.debugf("response %s", res.Status) + // http.Do expectes us to not only close but also fully read the response + // otherwise the Client's underlying RoundTripper may not be able to re-use a persistent TCP + // connection to the server for a subsequent "keep-alive" request. + ioutil.ReadAll(res.Body) return }