diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-05-05 11:33:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-05 11:33:16 +0100 |
commit | d9e71b93b68efb57582d02448883b8a1259205e8 (patch) | |
tree | ec9e43445e09cc10908a8ef50223310ec1cac627 /userapi | |
parent | 1bfe87aa5614d68cbb0cad127b375048cdc70ca9 (diff) |
Use `gomatrixserverlib.Client` instead of `http.Client` (#2421)
* Update to matrix-org/gomatrixserverlib#303
* Use `gomatrixserverlib.Client` for phone-home stats
* Use `gomatrixserverlib.Client` for push notifications
* Use `gomatrixserverlib.Client` for appservices
* Use `gomatrixserverlib.Client` for three-PID invites
Diffstat (limited to 'userapi')
-rw-r--r-- | userapi/util/phonehomestats.go | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/userapi/util/phonehomestats.go b/userapi/util/phonehomestats.go index ad93a50e..e24daba6 100644 --- a/userapi/util/phonehomestats.go +++ b/userapi/util/phonehomestats.go @@ -39,7 +39,7 @@ type phoneHomeStats struct { cfg *config.Dendrite db storage.Statistics isMonolith bool - client *http.Client + client *gomatrixserverlib.Client } type timestampToRUUsage struct { @@ -55,10 +55,9 @@ func StartPhoneHomeCollector(startTime time.Time, cfg *config.Dendrite, statsDB cfg: cfg, db: statsDB, isMonolith: cfg.IsMonolith, - client: &http.Client{ - Timeout: time.Second * 30, - Transport: http.DefaultTransport, - }, + client: gomatrixserverlib.NewClient( + gomatrixserverlib.WithTimeout(time.Second * 30), + ), } // start initial run after 5min @@ -152,8 +151,7 @@ func (p *phoneHomeStats) collect() { } request.Header.Set("User-Agent", "Dendrite/"+internal.VersionString()) - _, err = p.client.Do(request) - if err != nil { + if _, err = p.client.DoHTTPRequest(ctx, request); err != nil { logrus.WithError(err).Error("unable to send anonymous stats") return } |