make sure we re-use connection in poller

pull/3/head
Brad Rydzewski 4 years ago
parent e62bccbb2f
commit 0d98f4a0fe

@ -11,6 +11,7 @@ import (
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"time"
@ -267,7 +268,12 @@ func (p *HTTPClient) do(ctx context.Context, path, method string, in, out interf
res, err := p.client().Do(req)
if res != nil {
defer res.Body.Close()
defer func() {
// drain the response body so we can reuse
// this connection.
io.Copy(ioutil.Discard, io.LimitReader(res.Body, 4096))
res.Body.Close()
}()
}
if err != nil {
return res, err

Loading…
Cancel
Save