Skip to content

url: introduce URL_FLAGS_IS_DEFAULT_SCHEME_PORT flag - #20479

Closed
AyushG3112 wants to merge 6 commits into
nodejs:masterfrom
AyushG3112:fix-url-port-host-flag
Closed

url: introduce URL_FLAGS_IS_DEFAULT_SCHEME_PORT flag#20479
AyushG3112 wants to merge 6 commits into
nodejs:masterfrom
AyushG3112:fix-url-port-host-flag

Conversation

@AyushG3112

@AyushG3112AyushG3112 commented May 2, 2018

Copy link
Copy Markdown
Contributor

Introduce URL_FLAGS_IS_DEFAULT_SCHEME_PORT flag which is retured
when the parser detects that the port passed is the default port
for that scheme.

Fixes: #20465

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@nodejs-github-botnodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. labels May 2, 2018
@AyushG3112

Copy link
Copy Markdown
ContributorAuthor

If anyone could suggest where to add tests, that would be great. The fixture used in the existing test is the one provided by W3C and I'm not sure if I should modify that.

Comment threadsrc/node_url.cc Outdated

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.

The job done by IsDefaultSchemePort is pretty similar to what NormalizePort does already. Can we instead check url->port == -1 as an indicator for default scheme port?

Comment threadlib/internal/url.js Outdated

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.

In the case where URL_FLAGS_IS_DEFAULT_SCHEME_PORT is set, port should already be null. Unless I'm missing something there doesn't seem to be a need to have a conditional here.

@AyushG3112AyushG3112May 3, 2018

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

The reason I added the conditional is because the spec explicitly mentions setting the port to null in case of default scheme port.

I can remove it if you think we can just rely on C++ land to send us null in that situation though.

@TimothyGu

Copy link
Copy Markdown
Member

This PR also lacks tests. Please check out https://github.com/nodejs/node/blob/master/test/fixtures/url-setter-tests.js, add a test in there, and then upstream that test to https://github.com/w3c/web-platform-tests/blob/master/url/setters_tests.json.

@AyushG3112

Copy link
Copy Markdown
ContributorAuthor

@TimothyGu Fixed. PTAL. Also, to upstream the test, do I just open a PR for https://github.com/w3c/web-platform-tests/blob/master/url/setters_tests.json, or is there any other mechanism?

@AyushG3112

Copy link
Copy Markdown
ContributorAuthor

/cc @nodejs/url PTAL

@AyushG3112

AyushG3112 commented May 7, 2018

Copy link
Copy Markdown
ContributorAuthor

Ping

@joyeecheung

Copy link
Copy Markdown
Member

Also, to upstream the test, do I just open a PR for https://github.com/w3c/web-platform-tests/blob/master/url/setters_tests.json, or is there any other mechanism?

@AyushG3112 Yes I think so.

@AyushG3112

Copy link
Copy Markdown
ContributorAuthor

Test has landed at upstream W3C via web-platform-tests/wpt#10892, and I updated the ordering in test/fixtures/url-setter-tests.js to match the upstream contents.

@AyushG3112

Copy link
Copy Markdown
ContributorAuthor

@jasnell could you please run the CI on this? Also, would this be semver major or patch? Because this fixes a bug but changes the output of an action.

@jasnell

Copy link
Copy Markdown
Member

CI: https://ci.nodejs.org/job/node-test-pull-request/14750/

It's semver-patch :-)

@AyushG3112

Copy link
Copy Markdown
ContributorAuthor

Do any of the failures look related?

@targos

Copy link
Copy Markdown
Member

Failures look unrelated. New try: https://ci.nodejs.org/job/node-test-pull-request/14778/

@AyushG3112

Copy link
Copy Markdown
ContributorAuthor

Looks like builds timed out this time. Infra issue?

@AyushG3112

AyushG3112 commented May 11, 2018

Copy link
Copy Markdown
ContributorAuthor

Could anyone run the CI on this again please? thanks!

@jasnell

Copy link
Copy Markdown
Member

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request May 14, 2018
…d if new port is scheme default, a=testonly
Automatic update from web-platform-testsURL: host setter with default port against URL with non-default port
See nodejs/node#20479.
--
wpt-commits: f0fe4791f5b87491d8d9662832fae543e4edbca1
wpt-pr: 10892
Introduce `URL_FLAGS_IS_DEFAULT_SCHEME_PORT` flag which is retured
when the parser detects that the port passed is the default port
for that scheme.
Fixes: nodejs#20465
@AyushG3112

Copy link
Copy Markdown
ContributorAuthor

Rebased to master in hope of CI passing. Can this have another CI run please?

Comment threadsrc/node_url.cc Outdated
}
// the port is valid
url->port = NormalizePort(url->scheme, static_cast<int>(port));
if (url->port == -1) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would prefer no curlies, it's the more common style in our C++ code.

Comment threadsrc/node_url.h Outdated
XX(URL_FLAGS_HAS_QUERY, 0x200) \
XX(URL_FLAGS_HAS_FRAGMENT, 0x400)
XX(URL_FLAGS_HAS_FRAGMENT, 0x400) \
XX(URL_FLAGS_IS_DEFAULT_SCHEME_PORT, 0x800)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we add the final \ if it doesn't break this. It makes diffs cleaner.

@apapirovski

Copy link
Copy Markdown
Contributor

@AyushG3112

Copy link
Copy Markdown
ContributorAuthor

@apapirovski PTAL

@apapirovski

Copy link
Copy Markdown
Contributor

@apapirovskiapapirovski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reaffirming.

@AyushG3112

Copy link
Copy Markdown
ContributorAuthor

parallel/test-http2-compat-client-upload-reject failed with ECONNRESET on a few platforms, is it related by any chance?

@apapirovski

Copy link
Copy Markdown
Contributor

@AyushG3112 That one is definitely unrelated. We have a bug in http2 at the moment. (As an aside, I'm working on changes to http2 that will get rid of those failures.)

@AyushG3112

Copy link
Copy Markdown
ContributorAuthor

@apapirovski what would the next step here be then? Should we wait for the fix to land before landing this, or run the CI on the failed platforms till it is green, or ,assuming parallel/test-http2-compat-client-upload-reject is the only failure, ignore it?

@BridgeARBridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 18, 2018
BridgeAR pushed a commit to BridgeAR/node that referenced this pull request May 18, 2018
Introduce `URL_FLAGS_IS_DEFAULT_SCHEME_PORT` flag which is retured
when the parser detects that the port passed is the default port
for that scheme.
PR-URL: nodejs#20479Fixes: nodejs#20465
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@BridgeAR

Copy link
Copy Markdown
Member

Landed in 11892b0 🎉

@AyushG3112
AyushG3112 deleted the fix-url-port-host-flag branch May 20, 2018 09:09
MylesBorins pushed a commit that referenced this pull request May 22, 2018
Introduce `URL_FLAGS_IS_DEFAULT_SCHEME_PORT` flag which is retured
when the parser detects that the port passed is the default port
for that scheme.
PR-URL: #20479Fixes: #20465
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@addaleaxaddaleax mentioned this pull request May 22, 2018
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 3, 2019
…d if new port is scheme default, a=testonly
Automatic update from web-platform-testsURL: host setter with default port against URL with non-default port
See nodejs/node#20479.
--
wpt-commits: f0fe4791f5b87491d8d9662832fae543e4edbca1
wpt-pr: 10892
UltraBlame original commit: 497bd5c8c632f4828e13d82f8c7f0f6d7553126c
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
…d if new port is scheme default, a=testonly
Automatic update from web-platform-testsURL: host setter with default port against URL with non-default port
See nodejs/node#20479.
--
wpt-commits: f0fe4791f5b87491d8d9662832fae543e4edbca1
wpt-pr: 10892
UltraBlame original commit: 497bd5c8c632f4828e13d82f8c7f0f6d7553126c
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 3, 2019
…d if new port is scheme default, a=testonly
Automatic update from web-platform-testsURL: host setter with default port against URL with non-default port
See nodejs/node#20479.
--
wpt-commits: f0fe4791f5b87491d8d9662832fae543e4edbca1
wpt-pr: 10892
UltraBlame original commit: 497bd5c8c632f4828e13d82f8c7f0f6d7553126c
jwidar pushed a commit to jwidar/LatencyZeroGithub that referenced this pull request Sep 16, 2025
…d if new port is scheme default, a=testonly
Automatic update from web-platform-testsURL: host setter with default port against URL with non-default port
See nodejs/node#20479.
--
wpt-commits: f0fe4791f5b87491d8d9662832fae543e4edbca1
wpt-pr: 10892
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.c++Issues and PRs that require attention from people who are familiar with C++.lib / srcIssues and PRs related to general changes in the lib or src directory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

assigning a hostname with port 80 to URL.host will not override the existing port

8 participants

@AyushG3112@TimothyGu@joyeecheung@jasnell@targos@apapirovski@BridgeAR@nodejs-github-bot