fix: handle schema-less HTTP_PROXY env vars#4809
fix: handle schema-less HTTP_PROXY env vars#4809M-YasirGhaffar wants to merge 1 commit intonodejs:mainfrom
Conversation
Signed-off-by: M-YasirGhaffar <yasirghaffar.nust@gmail.com>
|
cc @joyeecheung can you take a look as well? |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4809 +/- ##
==========================================
- Coverage 93.26% 93.26% -0.01%
==========================================
Files 109 109
Lines 34090 34098 +8
==========================================
+ Hits 31794 31800 +6
- Misses 2296 2298 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Will this require adjustments in Node for |
|
@metcoder95 This shouldn't require any changes for |
|
As a user I'd find this behavior |
|
@joyeecheung curl does this. If you pass a proxy without a scheme it defaults to HTTP. git does too since it uses libcurl under the hood. Go's httpproxy package also prepends http:// when the scheme is missing. I think if someone sets HTTP_PROXY=myproxy:8080, they'd expect it to work, especially since curl handles it fine. The change is also non-breaking, URLs with explicit schemes go through unchanged. Sources:
|
|
Thanks for the pointers. I agree converging with what curl does is generally the safest. |
|
There are some related failures |
|
@mcollina could you point me to the specific failures? If you mean the macOS ECONNRESET in test/fetch/encoding.js and the Node 24/25 shared-builtin compilation ones, those seem unrelated to this change. Happy to dig further. |
This relates to...
Fixes #4736
Rationale
When HTTP_PROXY or HTTPS_PROXY is set without a URL scheme (e.g., localhost:8080 instead of http://localhost:8080), the EnvHttpProxyAgent fails. This PR adds automatic http:// prefix for schema-less proxy URLs, matching Go's httpproxy behavior.
Changes
Added normalizeProxyUrl() helper function in lib/dispatcher/env-http-proxy-agent.js. Also added tests in test/env-http-proxy-agent.js.
Features
N/A
Bug Fixes
Breaking Changes and Deprecations
None. This is additive behavior - existing URLs with explicit schemes are unchanged.
Status