MM-25701: Reuse HTTP client in sendAckToPushProxy (#14759)

We reuse the http client made for push notifications.
This leads to reuse of TCP connections rather than
creating a new client every time.
Этот коммит содержится в:
Agniva De Sarker
2020-06-23 00:08:06 +05:30
коммит произвёл GitHub
родитель 60b826824a
Коммит 78d44f3eab

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

@@ -4,6 +4,8 @@
package app
import (
"io"
"io/ioutil"
"net/http"
"runtime"
"strings"
@@ -370,14 +372,18 @@ func (a *App) SendAckToPushProxy(ack *model.PushNotificationAck) error {
return err
}
resp, err := a.HTTPService().MakeClient(true).Do(request)
resp, err := a.Srv().pushNotificationClient.Do(request)
if err != nil {
return err
}
defer resp.Body.Close()
// Reading the body to completion.
_, err = io.Copy(ioutil.Discard, resp.Body)
if err != nil {
return err
}
resp.Body.Close()
return nil
}
func (a *App) getMobileAppSessions(userId string) ([]*model.Session, *model.AppError) {