Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ext/http): Add port number only when the host is not defined #18258

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Sanskar531
Copy link
Contributor

Fixes issue from #18154

@jerry4718
Copy link

During my testing of node:http, I found that its original implementation was that opts.hostname should have a higher priority than opts.host.

In addition, if opts.hostname is not specified and :port is included in opts.host, there will also be a throw error in node.js, so we only need to adjust the priority of the host value.

Copy link
Collaborator

@aapoalas aapoalas left a comment

Choose a reason for hiding this comment

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

I'm somewhat worried that we might be causing another bug to appear with this change regarding host configurations that do not define a port. That kind of configuration is probably incorrect as it should use hostname in that case but we should check if that still works in Node or not.

@@ -341,7 +341,7 @@ class ClientRequest extends NodeWritable {
path = "/" + path;
}
return `${protocol}//${auth ? `${auth}@` : ""}${host}${
port === 80 ? "" : `:${port}`
(port === 80 || opts.host) ? "" : `:${port}`
Copy link
Collaborator

Choose a reason for hiding this comment

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

question: Is it possible, and does Node work with a configuration where host and port are both set and the host does not define a port? ie. Should we check for : presence in opts.host here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants