This repository was archived by the owner on Oct 7, 2020. It is now read-only.
Make http.request correctly parse {host: "hostname:port"}#72
Closed
nfriedly wants to merge 1 commit intonodejs:masterfrom
Closed
Make http.request correctly parse {host: "hostname:port"}#72nfriedly wants to merge 1 commit intonodejs:masterfrom
nfriedly wants to merge 1 commit intonodejs:masterfrom
Conversation
The issue:
http.request() treats host as an alternate form of hostname, which
it sort of is, except that host is (normally) allowed to contain a
port number.
Before this change, if host contains a port number and there isn't
a hostname field to override it, http.request() attempts a DNS
lookup on the entire host field, including the port number. This
always fails.
The fix:
If a host field is present, split it around ':' and use the first
portion as a fallback hostname and the second (if present) as a
fallback port. ("Fallback" meaning that the values from the host
field are only used when the hostname and port fields aren't set.)
Contributor
|
io.js is better for now, yeah. :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The issue:
http.request()treatshostas an alternate form ofhostname, which it sort of is, except thathostis (normally) allowed to contain a port number.Before this change, if
hostcontains a port number and there isn't ahostnamefield to override it,http.request()attempts a DNS lookup on the entire host field, including the port number. This always fails.The fix:
If a host field is present, split it around
':'and use the first portion as a fallbackhostnameand the second (if present) as a fallbackport. ("Fallback" meaning that the values from thehostfield are only used when thehostnameandportfields aren't set.)Includes a test to verify the correct behavior.
I originally filed an issue on joyent/node and submitted a patch there, but @jasnell said that this might be a better fit for nodejs/io.js or nodejs/node, so I'm sending the same patch to each. (The io.js patch is at nodejs/node#2271) Please merge into whichever repo is appropriate and close the other one.