Merge pull request #3095 from chengzhichao-xydt/codex/new-pr

fix(utils): add ok checks for http.Transport type assertions in CreateHTTPClient
This commit is contained in:
Mauro 2026-06-11 09:13:29 +02:00 committed by GitHub
commit f8462855d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -39,9 +39,17 @@ func CreateHTTPClient(proxyURL string, timeout time.Duration) (*http.Client, err
if proxy.Host == "" { if proxy.Host == "" {
return nil, fmt.Errorf("invalid proxy URL: missing host") return nil, fmt.Errorf("invalid proxy URL: missing host")
} }
client.Transport.(*http.Transport).Proxy = http.ProxyURL(proxy) tr, ok := client.Transport.(*http.Transport)
if !ok {
return nil, fmt.Errorf("internal error: transport is not *http.Transport")
}
tr.Proxy = http.ProxyURL(proxy)
} else { } else {
client.Transport.(*http.Transport).Proxy = http.ProxyFromEnvironment tr, ok := client.Transport.(*http.Transport)
if !ok {
return nil, fmt.Errorf("internal error: transport is not *http.Transport")
}
tr.Proxy = http.ProxyFromEnvironment
} }
return client, nil return client, nil