fix: select random browser user agents for outbound HTTP

This commit is contained in:
ji ruo committed 2026-11-11 19:13:38 +08:00
1 parent 17c2fc5e08
commit 171db405dd
18 files changed
+205 -71

No files matched your search

+1 -1
View File
@@ -122,7 +122,6 @@ func staticAssetExt(rawURL string) string {
}
func webFetchRunner(cfg actool.WebFetchConfig) func(context.Context, json.RawMessage, *actool.ToolContext) (actool.Result, error) {
userAgent := httpidentity.UserAgent()
client := newFetchClient(cfg)
// direct is the no-proxy fallback used when a proxied fetch fails for a
// proxy-caused reason (closed tunnel / failed CONNECT / TLS or HTTP2 mismatch):
@@ -152,6 +151,7 @@ func webFetchRunner(cfg actool.WebFetchConfig) func(context.Context, json.RawMes
if err != nil {
return actool.Errorf("Error: " + err.Error()), nil
}
userAgent := httpidentity.UserAgent()
req.Header.Set("User-Agent", userAgent)
resp, err := client.Do(req)
// One direct retry when the proxied attempt failed for a proxy-caused reason.