Skip to content
Snippets Groups Projects
Commit 764c5b76 authored by Travis Ralston's avatar Travis Ralston
Browse files

Clean up URL preview http code

parent 9ac19396
No related branches found
No related tags found
No related merge requests found
......@@ -25,7 +25,6 @@ func doHttpGet(urlPayload *m.UrlPayload, languageHeader string, ctx rcontext.Req
dialer := &net.Dialer{
Timeout: time.Duration(ctx.Config.TimeoutSeconds.UrlPreviews) * time.Second,
KeepAlive: time.Duration(ctx.Config.TimeoutSeconds.UrlPreviews) * time.Second,
DualStack: true,
}
dialContext := func(ctx2 context.Context, network, addr string) (conn net.Conn, e error) {
......@@ -48,7 +47,7 @@ func doHttpGet(urlPayload *m.UrlPayload, languageHeader string, ctx rcontext.Req
DialContext: dialContext,
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
// Based on https://github.com/matrix-org/gomatrixserverlib/blob/51152a681e69a832efcd934b60080b92bc98b286/client.go#L74-L90
DialTLS: func(network, addr string) (net.Conn, error) {
DialTLSContext: func(ctx2 context.Context, network, addr string) (net.Conn, error) {
rawconn, err := net.Dial(network, addr)
if err != nil {
return nil, err
......@@ -65,8 +64,8 @@ func doHttpGet(urlPayload *m.UrlPayload, languageHeader string, ctx rcontext.Req
},
}
client = &http.Client{
Transport: tr,
Timeout: time.Duration(ctx.Config.TimeoutSeconds.UrlPreviews) * time.Second,
Transport: tr,
}
} else {
client = &http.Client{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment