Fix network URLs in serve: loopback agents, own-origin public URLs, longer transfer timeouts

This commit is contained in:
Emil
2026-08-03 18:17:56 +03:00
parent b9f47e556c
commit e744e62d03
4 changed files with 92 additions and 11 deletions
+7 -1
View File
@@ -48,6 +48,12 @@ type Client struct {
}
func NewClient(baseURL string, tokens TokenProvider, timeout time.Duration) *Client {
// Payload transfers get a more generous budget than control calls: a large
// shard over a slow link easily outlives the API timeout.
transferTimeout := timeout * 4
if transferTimeout < 2*time.Minute {
transferTimeout = 2 * time.Minute
}
return &Client{
baseURL: strings.TrimRight(baseURL, "/"),
tokens: tokens,
@@ -57,7 +63,7 @@ func NewClient(baseURL string, tokens TokenProvider, timeout time.Duration) *Cli
CheckRedirect: func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse },
},
dlClient: &http.Client{
Timeout: timeout,
Timeout: transferTimeout,
CheckRedirect: func(req *http.Request, via []*http.Request) error {
if len(via) >= 10 {
return fmt.Errorf("too many redirects")