With go-ieproxy already available and the standard default transport still installed, attach its request-aware proxy function:

transport := http.DefaultTransport.(*http.Transport).Clone()
transport.Proxy = ieproxy.GetProxyFunc()
client := &http.Client{
    Transport: transport,
    Timeout: 30 * time.Second,
}

Import net/http, time and github.com/mattn/go-ieproxy, and make the workload's requests through client. The type assertion requires DefaultTransport to remain an http.Transport.

GetProxyFunc covers static settings, an explicit automatic-configuration script and fully automatic discovery. Its Windows lookup uses the current user's configuration, falling back to the registry if the initial API call fails.

OverrideEnvWithStaticProxy makes a different choice: it exports manual settings and cannot preserve automatic per-destination decisions. Use that conversion only for an intentionally static policy.

For a Windows service, the current user can differ from the desktop user whose browser works. Check the service account and actual destination when comparing the result. Discovery supplies a route candidate, not authentication or a guarantee the endpoint is reachable.

متعلقہ مضامین