chore: set User-Agent on all outgoing HTTP requests (#10867)

It's only polite, and it enables better troubleshooting in situations
like weird-ass requests to the upgrades download service.

---------

Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
Jakob Borg
2026-08-24 18:26:23 +00:00
committed by GitHub
parent e009ec07ff
commit 9af3c75f37
11 changed files with 31 additions and 8 deletions
+3
View File
@@ -25,6 +25,7 @@ import (
"golang.org/x/net/http2"
"github.com/syncthing/syncthing/internal/slogutil"
"github.com/syncthing/syncthing/lib/build"
"github.com/syncthing/syncthing/lib/connections/registry"
"github.com/syncthing/syncthing/lib/dialer"
"github.com/syncthing/syncthing/lib/events"
@@ -454,6 +455,7 @@ func (c *contextClient) Get(ctx context.Context, url string) (*http.Response, er
if err != nil {
return nil, err
}
req.Header.Set("User-Agent", build.UserAgent())
return c.Client.Do(req)
}
@@ -463,6 +465,7 @@ func (c *contextClient) Post(ctx context.Context, url, ctype string, data io.Rea
return nil, err
}
req.Header.Set("Content-Type", ctype)
req.Header.Set("User-Agent", build.UserAgent())
return c.Client.Do(req)
}