fix(httpclient): respect HTTP_PROXY/HTTPS_PROXY for streaming client#238
fix(httpclient): respect HTTP_PROXY/HTTPS_PROXY for streaming client#238Atarit0 wants to merge 1 commit into
Conversation
The Streaming HTTP client defines a custom http.Transport without setting Proxy, so it ignores HTTP_PROXY, HTTPS_PROXY and NO_PROXY env vars. This breaks playback for users behind corporate or local proxies, even though the rest of the codebase (which relies on http.DefaultTransport) already honors those vars. Add Proxy: http.ProxyFromEnvironment to the streaming Transport so it behaves consistently with the rest of cliamp.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Streaming HTTP client's transport is configured to respect HTTP_PROXY, HTTPS_PROXY, and NO_PROXY environment variables by setting ChangesHTTP Client Proxy Configuration
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
The Streaming HTTP client in
internal/httpclient/client.gosets a customhttp.Transport(to disable HTTP/2 for Icecast/SHOUTcast compatibility and to extend the header timeout) but doesn't setProxy, so it silently ignores theHTTP_PROXY,HTTPS_PROXYandNO_PROXYenvironment variables.This makes cliamp unusable for anyone behind a corporate or local proxy: the rest of the codebase relies on
http.DefaultTransport, which already honors those vars viahttp.ProxyFromEnvironment, so playback is the only thing that breaks — which is the most visible feature, and the failure mode (silent EOF / hang) is hard to diagnose.The fix
One-line addition:
Proxy: http.ProxyFromEnvironmentin the streaminghttp.Transport. Brings the streaming client in line with Go's default behavior and the rest of cliamp.var Streaming = &http.Client{ Transport: &http.Transport{ + Proxy: http.ProxyFromEnvironment, ResponseHeaderTimeout: 30 * time.Second, TLSNextProto: make(map[string]func(authority string, c *tls.Conn) http.RoundTripper), }, }Tested
strings cliamp | grep ProxyFromEnvironmentreturns the symbol.HTTPS_PROXY=socks5://localhost:<port>).ProxyFromEnvironmentreturns nil → behavior identical to current code).Why this is safe
http.ProxyFromEnvironmentis the same helper used byhttp.DefaultTransport. With no proxy env vars set, the call is a no-op and the transport behaves exactly as before. With proxy env vars set, the streaming client gains the behavior every other HTTP client in cliamp already has.Summary by CodeRabbit