···20// where the validation overhead is problematic.
21var TrustedClient http.Client
220000000023func init() {
24 // Initialize the trusted client first.
25 TrustedClient = http.Client{
···3839 // When running under `go test` the test binary name typically ends with ".test".
40 // In that case, use the trusted client to avoid SSRF blocking for localhost tests.
41- if len(os.Args) > 0 && strings.HasSuffix(os.Args[0], ".test") {
42 Client = TrustedClient
43 }
44}
···20// where the validation overhead is problematic.
21var TrustedClient http.Client
2223+type ClientOptions struct {
24+ OverrideInTest bool
25+}
26+27+var defaultClientOptions = ClientOptions{
28+ OverrideInTest: true,
29+}
30+31func init() {
32 // Initialize the trusted client first.
33 TrustedClient = http.Client{
···4647 // When running under `go test` the test binary name typically ends with ".test".
48 // In that case, use the trusted client to avoid SSRF blocking for localhost tests.
49+ if defaultClientOptions.OverrideInTest && len(os.Args) > 0 && strings.HasSuffix(os.Args[0], ".test") {
50 Client = TrustedClient
51 }
52}