aboutsummaryrefslogtreecommitdiff
path: root/internal/pushgateway
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-05-10 11:08:10 +0100
committerNeil Alexander <neilalexander@users.noreply.github.com>2022-05-10 11:08:10 +0100
commit77722c5a4f5330f6fe517edc2d11bcba8c1fc274 (patch)
tree2c1da8cb54d9726e091a9e88b1386af2438322ee /internal/pushgateway
parent1b3fa9689ca28de2337b67253089e286694c60e9 (diff)
Back out matrix-org/dendrite#2421 by restoring `http.Client`s
This creates problems with non-HTTPS endpoints and should fix #2444.
Diffstat (limited to 'internal/pushgateway')
-rw-r--r--internal/pushgateway/client.go22
1 files changed, 13 insertions, 9 deletions
diff --git a/internal/pushgateway/client.go b/internal/pushgateway/client.go
index 231327a1..95f5afd9 100644
--- a/internal/pushgateway/client.go
+++ b/internal/pushgateway/client.go
@@ -3,28 +3,32 @@ 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 *gomatrixserverlib.Client
+ hc *http.Client
}
// NewHTTPClient creates a new Push Gateway client.
func NewHTTPClient(disableTLSValidation bool) Client {
- return &httpClient{
- hc: gomatrixserverlib.NewClient(
- gomatrixserverlib.WithTimeout(time.Second*30),
- gomatrixserverlib.WithKeepAlives(false),
- gomatrixserverlib.WithSkipVerify(disableTLSValidation),
- ),
+ hc := &http.Client{
+ Timeout: 30 * time.Second,
+ Transport: &http.Transport{
+ DisableKeepAlives: true,
+ TLSClientConfig: &tls.Config{
+ InsecureSkipVerify: disableTLSValidation,
+ },
+ Proxy: http.ProxyFromEnvironment,
+ },
}
+ return &httpClient{hc: hc}
}
func (h *httpClient) Notify(ctx context.Context, url string, req *NotifyRequest, resp *NotifyResponse) error {
@@ -41,7 +45,7 @@ func (h *httpClient) Notify(ctx context.Context, url string, req *NotifyRequest,
}
hreq.Header.Set("Content-Type", "application/json")
- hresp, err := h.hc.DoHTTPRequest(ctx, hreq)
+ hresp, err := h.hc.Do(hreq)
if err != nil {
return err
}