Honor HTTP(S)_PROXY in the default HTTP client#253
Closed
yotamazriel wants to merge 1 commit into
Closed
Conversation
init() replaces http.DefaultClient with a client built on a bare
http.Transport{}, which has no Proxy set. This makes every http.Get in
the binary (and the bundled helm-charts installer) ignore
HTTP_PROXY/HTTPS_PROXY/NO_PROXY, so installs behind a corporate proxy
fail with direct-DNS errors (e.g. resolving api.github.com) even when
the proxy env is set correctly.
Set Proxy: http.ProxyFromEnvironment on the transport. This also clears
the misleading "No internet connection found" warning, since
hasInternet() uses the same client.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
init()inpkg/api/utils.goreplaces Go's globalhttp.DefaultClientwith a client built on a barehttp.Transport{}(noProxyset). Everyhttp.Getin the binary — including the bundled helm-charts installer'sGetReleasesPage— therefore silently ignoresHTTP_PROXY/HTTPS_PROXY/NO_PROXY.Behind a corporate proxy (no direct internet egress),
leap server installfails with:even when the proxy env vars are set correctly. Confirmed root cause:
curlusing the exact same env reaches GitHub (200), whileleapdoes a direct DNS lookup — because itshttp.DefaultClienthas no proxy.Fix
Set
Proxy: http.ProxyFromEnvironmenton the transport inNewDefaultClient(). This restores standard proxy support for the whole binary.It also clears the misleading
No internet connection foundwarning, sincehasInternet()(cmd/server/utils.go) uses the same client.Testing
Built for linux/amd64 and verified on a customer host behind an authenticated Squid proxy: the GitHub release lookup now succeeds through the proxy, and the install proceeds.
🤖 Generated with Claude Code