MCPcopy
hub / github.com/golang/net / FromEnvironmentUsing

Function FromEnvironmentUsing

proxy/proxy.go:40–63  ·  view source on GitHub ↗

FromEnvironmentUsing returns the dialer specify by the proxy-related variables in the environment and makes underlying connections using the provided forwarding Dialer (for instance, a *net.Dialer with desired configuration).

(forward Dialer)

Source from the content-addressed store, hash-verified

38// using the provided forwarding Dialer (for instance, a *net.Dialer
39// with desired configuration).
40func FromEnvironmentUsing(forward Dialer) Dialer {
41 allProxy := allProxyEnv.Get()
42 if len(allProxy) == 0 {
43 return forward
44 }
45
46 proxyURL, err := url.Parse(allProxy)
47 if err != nil {
48 return forward
49 }
50 proxy, err := FromURL(proxyURL, forward)
51 if err != nil {
52 return forward
53 }
54
55 noProxy := noProxyEnv.Get()
56 if len(noProxy) == 0 {
57 return proxy
58 }
59
60 perHost := NewPerHost(proxy, forward)
61 perHost.AddFromString(noProxy)
62 return perHost
63}
64
65// proxySchemes is a map from URL schemes to a function that creates a Dialer
66// from a URL with such a scheme.

Callers 2

FromEnvironmentFunction · 0.85
TestFromEnvironmentUsingFunction · 0.85

Calls 5

AddFromStringMethod · 0.95
FromURLFunction · 0.85
NewPerHostFunction · 0.85
GetMethod · 0.45
ParseMethod · 0.45

Tested by 1

TestFromEnvironmentUsingFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…