Skip to content

Commit

Permalink
Timeout well-known requests (#438)
Browse files Browse the repository at this point in the history
  • Loading branch information
S7evinK authored Sep 10, 2024
1 parent f80a3be commit 01f3d2e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fclient/well_known.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ func LookupWellKnown(ctx context.Context, serverNameType spec.ServerName) (*Well
wellKnownPath := "/.well-known/matrix/server"

// Request server's well-known record

req, err := http.NewRequestWithContext(ctx, "GET", "https://"+serverName+wellKnownPath, nil)
if err != nil {
return nil, err
}
resp, err := http.DefaultClient.Do(req)
// Given well-known should be quite small and fast to fetch, timeout the request after 30s.
client := http.Client{Timeout: time.Second * 30}
resp, err := client.Do(req)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 01f3d2e

Please sign in to comment.