summaryrefslogtreecommitdiffstats
path: root/app/webhook.go
diff options
context:
space:
mode:
authorTorsten Juergeleit <torsten.juergeleit@gmail.com>2017-05-31 16:34:05 +0200
committerHarrison Healey <harrisonmhealey@gmail.com>2017-05-31 10:34:05 -0400
commitfdf1164aee36d60b34ca82c07fe02b68e972f53a (patch)
treedecf173e9b6fb8d8f3c10463d065ad9234fc3391 /app/webhook.go
parentddc996f33fc39b2b8f4705d6e1232ccbad1ee4c7 (diff)
downloadchat-fdf1164aee36d60b34ca82c07fe02b68e972f53a.tar.gz
chat-fdf1164aee36d60b34ca82c07fe02b68e972f53a.tar.bz2
chat-fdf1164aee36d60b34ca82c07fe02b68e972f53a.zip
PLT-5705 Created a single source of http.Client creation logic with internet proxy support, reasonable timeouts and optional insecure connections (#6503)
Diffstat (limited to 'app/webhook.go')
-rw-r--r--app/webhook.go13
1 files changed, 2 insertions, 11 deletions
diff --git a/app/webhook.go b/app/webhook.go
index e095c1b80..1ec96a32e 100644
--- a/app/webhook.go
+++ b/app/webhook.go
@@ -4,9 +4,7 @@
package app
import (
- "crypto/tls"
"io"
- "io/ioutil"
"net/http"
"regexp"
"strings"
@@ -87,23 +85,16 @@ func handleWebhookEvents(post *model.Post, team *model.Team, channel *model.Chan
body = strings.NewReader(payload.ToFormValues())
contentType = "application/x-www-form-urlencoded"
}
- tr := &http.Transport{
- TLSClientConfig: &tls.Config{InsecureSkipVerify: *utils.Cfg.ServiceSettings.EnableInsecureOutgoingConnections},
- }
- client := &http.Client{Transport: tr}
for _, url := range hook.CallbackURLs {
go func(url string) {
req, _ := http.NewRequest("POST", url, body)
req.Header.Set("Content-Type", contentType)
req.Header.Set("Accept", "application/json")
- if resp, err := client.Do(req); err != nil {
+ if resp, err := utils.HttpClient().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()
- }()
+ defer CloseBody(resp)
respProps := model.MapFromJson(resp.Body)
if text, ok := respProps["text"]; ok {