-
Notifications
You must be signed in to change notification settings - Fork 7.3k
http.request fails when host contains port #25751
Comments
Fixed, with a test :) |
I also though about possibly adding a |
This is due to the fact that the object you're passing into
Closing as it's not actually a bug in node. Yes, the API could be doing things better, but this is the way it's worked for a while and it's not going to be changing in either v0.10 or v0.12. |
I respectfully disagree. There is enough information to make the request correctly, the patch I provided (https://github.com/joyent/node/pull/25752/files) does exactly that with a simple 3-line change. This bug was found when writing unit tests for a module that normally connects to a remote server. I change the host that my library uses from "example.com" to "localhost:12345" to match the mock remote server that I set up and then run the tests. This works correctly with my patch, but fails because node passes the wrong value to the dns lookup in the current 0.12 release. |
(BTW, I'm OK if the fix doesn't get included in 0.10 and 0.12 - I'd just like to see it included eventually.) |
There are a number of issues with the url.parse response and the way url's are reconstructed from it. It's definitely a known issue, but it's certainly not going to be changing here. What I would recommend is moving discussion over to either the nodejs/io.js or nodejs/node repos. |
Oh, alright. Thanks! |
host
is different fromhostname
in that it may contain a port number. For example:However,
http.request({options})
treats both fields ashostname
and attempts an invalid DNS lookup when given ahost
with a port. For example:> Error: getaddrinfo ENOTFOUND localhost:8080 at errnoException (dns.js:44:10) at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26)
The text was updated successfully, but these errors were encountered: