client: allow using custom http client for .well-known resolution
Some checks are pending
Go / Lint (latest) (push) Waiting to run
Go / Build (old, libolm) (push) Waiting to run
Go / Build (latest, libolm) (push) Waiting to run
Go / Build (old, goolm) (push) Waiting to run
Go / Build (latest, goolm) (push) Waiting to run

This commit is contained in:
Tulir Asokan 2025-07-20 14:23:20 +03:00
commit 65a64c8044

View file

@ -139,6 +139,10 @@ type IdentityServerInfo struct {
// Use ParseUserID to extract the server name from a user ID.
// https://spec.matrix.org/v1.2/client-server-api/#server-discovery
func DiscoverClientAPI(ctx context.Context, serverName string) (*ClientWellKnown, error) {
return DiscoverClientAPIWithClient(ctx, &http.Client{Timeout: 30 * time.Second}, serverName)
}
func DiscoverClientAPIWithClient(ctx context.Context, client *http.Client, serverName string) (*ClientWellKnown, error) {
wellKnownURL := url.URL{
Scheme: "https",
Host: serverName,
@ -153,7 +157,6 @@ func DiscoverClientAPI(ctx context.Context, serverName string) (*ClientWellKnown
req.Header.Set("Accept", "application/json")
req.Header.Set("User-Agent", DefaultUserAgent+" (.well-known fetcher)")
client := &http.Client{Timeout: 30 * time.Second}
resp, err := client.Do(req)
if err != nil {
return nil, err