From a495546f8d6f7cc0c73d89ab1a381a75dd91cded Mon Sep 17 00:00:00 2001 From: Weston Schmidt Date: Wed, 16 Aug 2017 12:40:20 -0700 Subject: [PATCH] Close the body and re-use the connection. --- src/caduceus/outboundSender.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/caduceus/outboundSender.go b/src/caduceus/outboundSender.go index 697dcde6..030d7f80 100644 --- a/src/caduceus/outboundSender.go +++ b/src/caduceus/outboundSender.go @@ -11,6 +11,8 @@ import ( "github.com/Comcast/webpa-common/logging" "github.com/Comcast/webpa-common/webhook" "hash" + "io" + "io/ioutil" "net/http" "net/url" "regexp" @@ -432,6 +434,13 @@ func (obs *CaduceusOutboundSender) worker(id int) { work.req.Telemetry.Status = TelemetryStatusPartialSuccess obs.profiler.Send(work.req.Telemetry) } + + // read until the response is complete before closing to allow + // connection reuse + if nil != resp.Body { + io.Copy(ioutil.Discard, resp.Body) + resp.Body.Close() + } } } }