From 3461a7b20704464ee3c19a3dd31805e4c5c1fc4f Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Thu, 12 Oct 2017 08:00:53 -0700 Subject: Add back consumeAndClose functionality. (#7608) * consume bodies for action button integrations, webrtc gateway, oauth endpoint * Fixing a couple more places, switching to io.Copy to ioutil.Discard, adding a comment to help prevent future performance regressions --- app/server.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'app/server.go') diff --git a/app/server.go b/app/server.go index 3802c2eec..c509d0440 100644 --- a/app/server.go +++ b/app/server.go @@ -5,6 +5,8 @@ package app import ( "crypto/tls" + "io" + "io/ioutil" "net" "net/http" "strings" @@ -208,3 +210,11 @@ func (a *App) StopServer() { a.Srv.GracefulServer = nil } } + +// This is required to re-use the underlying connection and not take up file descriptors +func consumeAndClose(r *http.Response) { + if r.Body != nil { + io.Copy(ioutil.Discard, r.Body) + r.Body.Close() + } +} -- cgit v1.2.3-1-g7c22