From 6d52033df6319ced7faf99b3890b49ca4bc3f2a2 Mon Sep 17 00:00:00 2001 From: Nimi Wariboko Jr Date: Tue, 18 Sep 2018 11:29:10 -0700 Subject: [PATCH] Close request body so connections aren't leaked --- gatekeeper.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gatekeeper.go b/gatekeeper.go index 0fb5c9e..c530f0a 100644 --- a/gatekeeper.go +++ b/gatekeeper.go @@ -357,6 +357,7 @@ func (g *Gatekeeper) GetRoleId(roleName string, authToken string) (string, error RedirectHeaders: true, }.WithHeader("X-Vault-Token", authToken)}.Do() if err == nil { + defer r.Body.Close() switch r.StatusCode { case 200: var resp struct { @@ -394,6 +395,7 @@ func (g *Gatekeeper) GetSecretId(roleName string, authToken string) (string, err Method: "POST", }.WithHeader("X-Vault-Token", authToken)}.Do() if err == nil { + defer r.Body.Close() switch r.StatusCode { case 200: var resp struct { @@ -607,6 +609,7 @@ func (g *Gatekeeper) TokenTtl() (time.Duration, error) { Method: "GET", }.WithHeader("X-Vault-Token", token)}.Do() if err == nil { + defer r.Body.Close() switch r.StatusCode { case 200: var resp struct { @@ -648,6 +651,7 @@ func (g *Gatekeeper) RenewToken() error { Method: "POST", }.WithHeader("X-Vault-Token", token)}.Do() if err == nil { + defer r.Body.Close() switch r.StatusCode { case 200, 204: return nil