Skip to content

Commit 01f3d2e

Browse files
authored
Timeout well-known requests (#438)
1 parent f80a3be commit 01f3d2e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fclient/well_known.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ func LookupWellKnown(ctx context.Context, serverNameType spec.ServerName) (*Well
3838
wellKnownPath := "/.well-known/matrix/server"
3939

4040
// Request server's well-known record
41-
4241
req, err := http.NewRequestWithContext(ctx, "GET", "https://"+serverName+wellKnownPath, nil)
4342
if err != nil {
4443
return nil, err
4544
}
46-
resp, err := http.DefaultClient.Do(req)
45+
// Given well-known should be quite small and fast to fetch, timeout the request after 30s.
46+
client := http.Client{Timeout: time.Second * 30}
47+
resp, err := client.Do(req)
4748
if err != nil {
4849
return nil, err
4950
}

0 commit comments

Comments
 (0)