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:
+7
-2
@@ -337,7 +337,12 @@ func parseResponse(ctx context.Context, deviceType string, addr *net.UDPAddr, re
|
||||
}
|
||||
|
||||
deviceUUID := strings.TrimPrefix(strings.Split(deviceUSN, "::")[0], "uuid:")
|
||||
response, err = http.Get(deviceDescriptionLocation)
|
||||
req, err := http.NewRequestWithContext(ctx, http.MethodGet, deviceDescriptionLocation, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Header.Set("User-Agent", build.UserAgent())
|
||||
response, err = http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -582,7 +587,7 @@ func soapRequestWithIP(ctx context.Context, url, service, function, message stri
|
||||
}
|
||||
req.Close = true
|
||||
req.Header.Set("Content-Type", `text/xml; charset="utf-8"`)
|
||||
req.Header.Set("User-Agent", "syncthing/1.0")
|
||||
req.Header.Set("User-Agent", build.UserAgent())
|
||||
req.Header["SOAPAction"] = []string{fmt.Sprintf(`"%s#%s"`, service, function)} // Enforce capitalization in header-entry for sensitive routers. See issue #1696
|
||||
req.Header.Set("Connection", "Close")
|
||||
req.Header.Set("Cache-Control", "no-cache")
|
||||
|
||||
Reference in New Issue
Block a user