Skip to content

http: normalize CONNECT request paths - #64876

Open
efekrskl wants to merge 2 commits into
nodejs:mainfrom
efekrskl:fix/http-connect-path-url
Open

http: normalize CONNECT request paths#64876
efekrskl wants to merge 2 commits into
nodejs:mainfrom
efekrskl:fix/http-connect-path-url

Conversation

@efekrskl

Copy link
Copy Markdown
Member

Fixes #34347

Partially a revival of #34412 which was apparently moving in the right direction but got stalled and closed

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/http
  • @nodejs/net

@efekrskl
efekrskl force-pushed the fix/http-connect-path-url branch from 987fc94 to 8172f67 Compare July 31, 2026 16:37
@nodejs-github-bot nodejs-github-bot added http Issues or PRs related to the http subsystem. needs-ci PRs that need a full CI run. labels Jul 31, 2026
Comment thread lib/_http_client.js Outdated

try {
validatePort(match[2], 'options.path', false);
const url = new URL(`http://${path}`);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const url = new URL(`http://${path}`);
const url = URL.parse(`http://${path}`);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, I ended up using internal URLParse as there's a lint rule against Url.parse (lib/eslint.config_partial.mjs:34)

Thanks!

Comment thread lib/_http_client.js Outdated
return false;
}

try {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid throwing error please

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.14286% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.29%. Comparing base (a46087d) to head (673924c).

Files with missing lines Patch % Lines
lib/_http_client.js 97.14% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #64876      +/-   ##
==========================================
- Coverage   90.29%   90.29%   -0.01%     
==========================================
  Files         760      760              
  Lines      247061   247094      +33     
  Branches    46584    46601      +17     
==========================================
+ Hits       223096   223120      +24     
- Misses      15437    15454      +17     
+ Partials     8528     8520       -8     
Files with missing lines Coverage Δ
lib/_http_client.js 97.61% <97.14%> (-0.02%) ⬇️

... and 25 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@efekrskl
efekrskl requested a review from anonrig August 1, 2026 12:46
@efekrskl
efekrskl force-pushed the fix/http-connect-path-url branch from 7cb68d6 to 673924c Compare August 1, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

http Issues or PRs related to the http subsystem. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Passing a URL instance with a CONNECT method results in an invalid path

3 participants