PLT-5705 Created a single source of http.Client creation logic with internet proxy support, reasonable timeouts and optional insecure connections (#6503)

Этот коммит содержится в:
Torsten Juergeleit
2017-05-31 16:34:05 +02:00
коммит произвёл Harrison Healey
родитель ddc996f33f
Коммит fdf1164aee
9 изменённых файлов: 117 добавлений и 86 удалений

Просмотреть файл

@@ -6,7 +6,6 @@ package app
import (
"crypto/hmac"
"crypto/sha1"
"crypto/tls"
"encoding/base64"
"net/http"
"strconv"
@@ -60,11 +59,7 @@ func GetWebrtcToken(sessionId string) (string, *model.AppError) {
rq, _ := http.NewRequest("POST", *utils.Cfg.WebrtcSettings.GatewayAdminUrl, strings.NewReader(model.MapToJson(data)))
rq.Header.Set("Content-Type", "application/json")
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: *utils.Cfg.ServiceSettings.EnableInsecureOutgoingConnections},
}
httpClient := &http.Client{Transport: tr}
if rp, err := httpClient.Do(rq); err != nil {
if rp, err := utils.HttpClient().Do(rq); err != nil {
return "", model.NewAppError("WebRTC.Token", "model.client.connecting.app_error", nil, err.Error(), http.StatusInternalServerError)
} else if rp.StatusCode >= 300 {
defer CloseBody(rp)