fix(net): respect HTTP proxy environment variables #210
+121
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Proxy: http.ProxyFromEnvironmentto all customhttp.Transportand barehttp.Clientinstances so thatHTTP_PROXY,HTTPS_PROXY, andALL_PROXYenvironment variables are honoredno such host) when running inside sandboxed environments that route traffic through HTTP/SOCKS proxiesProblem
A custom
http.Transport{}defaultsProxytonil, unlikehttp.DefaultTransportwhich useshttp.ProxyFromEnvironment. The base transport inoptionsForAccountScopes(and barehttp.Clientinstances used for OAuth token exchanges) silently bypassed all proxy settings.Changes
Seven locations fixed across four packages:
internal/googleapi/client.go:128internal/googleapi/client.go:81internal/googleapi/service_account.go:23internal/googleauth/token_check.go:32internal/googleauth/token_email.go:38internal/googleauth/accounts_server.go:526internal/cmd/gmail_watch_cmds.go:319Test plan
TestProxyEnvRespectedverifies the full transport chain and OAuth client route throughHTTP_PROXYmake lintandmake fmt-checkpass🤖 Generated with Claude Code