aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-05-05 11:33:16 +0100
committerGitHub <noreply@github.com>2022-05-05 11:33:16 +0100
commitd9e71b93b68efb57582d02448883b8a1259205e8 (patch)
treeec9e43445e09cc10908a8ef50223310ec1cac627 /internal
parent1bfe87aa5614d68cbb0cad127b375048cdc70ca9 (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 'internal')
-rw-r--r--internal/pushgateway/client.go21
1 files changed, 9 insertions, 12 deletions
diff --git a/internal/pushgateway/client.go b/internal/pushgateway/client.go
index 49907cee..231327a1 100644
--- a/internal/pushgateway/client.go
+++ b/internal/pushgateway/client.go
@@ -3,31 +3,28 @@ package pushgateway
import (
"bytes"
"context"
- "crypto/tls"
"encoding/json"
"fmt"
"net/http"
"time"
+ "github.com/matrix-org/gomatrixserverlib"
"github.com/opentracing/opentracing-go"
)
type httpClient struct {
- hc *http.Client
+ hc *gomatrixserverlib.Client
}
// NewHTTPClient creates a new Push Gateway client.
func NewHTTPClient(disableTLSValidation bool) Client {
- hc := &http.Client{
- Timeout: 30 * time.Second,
- Transport: &http.Transport{
- DisableKeepAlives: true,
- TLSClientConfig: &tls.Config{
- InsecureSkipVerify: disableTLSValidation,
- },
- },
+ return &httpClient{
+ hc: gomatrixserverlib.NewClient(
+ gomatrixserverlib.WithTimeout(time.Second*30),
+ gomatrixserverlib.WithKeepAlives(false),
+ gomatrixserverlib.WithSkipVerify(disableTLSValidation),
+ ),
}
- return &httpClient{hc: hc}
}
func (h *httpClient) Notify(ctx context.Context, url string, req *NotifyRequest, resp *NotifyResponse) error {
@@ -44,7 +41,7 @@ func (h *httpClient) Notify(ctx context.Context, url string, req *NotifyRequest,
}
hreq.Header.Set("Content-Type", "application/json")
- hresp, err := h.hc.Do(hreq)
+ hresp, err := h.hc.DoHTTPRequest(ctx, hreq)
if err != nil {
return err
}