diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-06-02 15:40:34 -0400 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2016-06-02 12:40:34 -0700 |
commit | 0788e836475722123c36835489396d65c6f9b252 (patch) | |
tree | ff18b2e5042e3023f87eb3efffd8b8e7f8f2e75e /api | |
parent | 848a8663ed7f856aee3f801a62b82e87b20de0ea (diff) | |
download | chat-0788e836475722123c36835489396d65c6f9b252.tar.gz chat-0788e836475722123c36835489396d65c6f9b252.tar.bz2 chat-0788e836475722123c36835489396d65c6f9b252.zip |
Close HTTP response bodies properly in golang driver (and some api functions) (#3217)
Diffstat (limited to 'api')
-rw-r--r-- | api/command.go | 1 | ||||
-rw-r--r-- | api/post.go | 5 |
2 files changed, 6 insertions, 0 deletions
diff --git a/api/command.go b/api/command.go index e1c576bba..953340ccc 100644 --- a/api/command.go +++ b/api/command.go @@ -203,6 +203,7 @@ func executeCommand(c *Context, w http.ResponseWriter, r *http.Request) { handleResponse(c, w, response, channelId, cmd, false) } } else { + defer resp.Body.Close() body, _ := ioutil.ReadAll(resp.Body) c.Err = model.NewLocAppError("command", "api.command.execute_command.failed_resp.app_error", map[string]interface{}{"Trigger": trigger, "Status": resp.Status}, string(body)) } diff --git a/api/post.go b/api/post.go index 875f30ba5..831591784 100644 --- a/api/post.go +++ b/api/post.go @@ -8,6 +8,7 @@ import ( "fmt" "html/template" "io" + "io/ioutil" "net/http" "net/url" "path/filepath" @@ -428,6 +429,10 @@ func handleWebhookEvents(c *Context, post *model.Post, team *model.Team, channel if resp, err := client.Do(req); err != nil { l4g.Error(utils.T("api.post.handle_webhook_events_and_forget.event_post.error"), err.Error()) } else { + defer func() { + ioutil.ReadAll(resp.Body) + resp.Body.Close() + }() respProps := model.MapFromJson(resp.Body) // copy the context and create a mock session for posting the message |