| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
It looks like the file permissions for _http_client.js were changed? |
Sorry, something went wrong.
|
Thank you for noticing, and I apologize for the mistake. Not sure how that happened, but I'll update the PR with the permissions change reverted. |
Sorry, something went wrong.
There was a problem hiding this comment.
Maybe use net.isIPv6(hostHeader) here instead?
Sorry, something went wrong.
There was a problem hiding this comment.
very minor nit... these can use template strings now.. [${hostHeader}]... not critical tho :-)
Sorry, something went wrong.
There was a problem hiding this comment.
Isn't string concatenation faster than template strings?
Sorry, something went wrong.
There was a problem hiding this comment.
I want to say that some benchmarks have shown that template strings do not introduce any performance issues, maybe even improve performance. Will have to look and see if I can find them though.
Sorry, something went wrong.
|
LGTM |
Sorry, something went wrong.
There was a problem hiding this comment.
if you wrap this in a common.mustCall(function(req, res) { }), then the hadRequest can be be totally removed. It doesn't look like hadError is used at all, so that can be removed. With those two gone, we can also remove the process.on('exit') listener.
Sorry, something went wrong.
|
If you can address the nits that both myself and @jasnell have mentioned, LGTM. Once that is done, we can run the CI and make sure everything is passing. Thanks for the contribution! |
Sorry, something went wrong.
There was a problem hiding this comment.
isn't this too heavyweight?
Sorry, something went wrong.
There was a problem hiding this comment.
In my initial PR, IPv6 checking was done by hostHeader.indexOf(':'), just as you also suggested in #5308
However, now I agree that net.isIPv6() is a much more reliable way of testing for IPv6.
I don't necessarily think it's too heavyweight, since it relies on uv_inet_pton. I guess it's slightly slower than indexOf, but since it also checks for valid characters inside the string, I believe it's worth the extra cycles.
Sorry, something went wrong.
There was a problem hiding this comment.
There were no check for correctness here before, so I assume that there are two possibilities:
isIPv6 involves calling C++ code and also checking if argument is IPv4 before checking if it's IPv6.
Sorry, something went wrong.
There was a problem hiding this comment.
Host value doesn't pass through proper validation. It actually relies on either url.parse() to produce a host value, or simply takes options.hostname || options.host. At this stage, especially if options object is passed to the request(), hostHeader could even be www.domain.tld:3000, before reaching my code; (which is not wrong, only unsupported atm). In this case, a simple : check would yield an invalid Host header [www.domain.tld:3000].
Secondly, the RFC says that if (IP is IPv6) then [IP], which in my view makes it mandatory to make absolutely sure that whatever I enclose within square brackets, is an IPv6 address and not anything else (even if invalid).
I've been considering all of the above right from my initial PR, including the fact that indexOf is faster than isIPv6. However, since all points of view express advantages and disadvantages, I also opted for net.isIPv6 in the end, because that allows my fix to avoid type assumptions and ultimately make the code terse, and enforces the RFC statement.
While the above explains my preference for net.isIPv6, if there's consensus on reverting it back to : matching, I'll happily do it.
Sorry, something went wrong.
There was a problem hiding this comment.
Secondly, the RFC says that if (IP is IPv6) then [IP], which in my view makes it mandatory to make absolutely sure that whatever I enclose within square bracket
It doesn't say that wrapping invalid host with brackets makes it more invalid, that's all I'm saying.
Sorry, something went wrong.
There was a problem hiding this comment.
Doing a quick scan for two :'s may be a simple workaround here. I agree that dropping down to the native code to check is a bit overweight for this.
Sorry, something went wrong.
There was a problem hiding this comment.
Yea, I agree. Just ran some benchmarks and net.isIPv6 runs about 3-6 times slower than an indexOf check here.
Sorry, something went wrong.
|
I've just pushed two commits with the following:
|
Sorry, something went wrong.
Sorry, something went wrong.
|
Still LGTM. @nodejs/http @nodejs/ctc |
Sorry, something went wrong.
|
LGTM |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
nit: would just make this const server
Sorry, something went wrong.
|
CI is green, added a small nit. |
Sorry, something went wrong.
|
Modified to use const server |
Sorry, something went wrong.
|
New CI after the rebase: https://ci.nodejs.org/job/node-test-pull-request/2021/ |
Sorry, something went wrong.
|
Apparently CI failed on "node-test-binary-arm » 3,pi1-raspbian-wheezy" https://ci.nodejs.org/job/node-test-binary-arm/1448//console |
Sorry, something went wrong.
|
No, we've been seeing an increase in random flakiness with tests on the pi devices. I don't think the failure is related. /cc @nodejs/testing |
Sorry, something went wrong.
|
Can I ask you to please squash the commits down into one commit now? Thank you! |
Sorry, something went wrong.
|
Sure, done. |
Sorry, something went wrong.
|
Thanks, and sorry for having it under internet in the first place. It's adjusted now. |
Sorry, something went wrong.
|
No problem at all. Sorry for just noticing :] I've started another CI run: https://ci.nodejs.org/job/node-test-pull-request/2063/ |
Sorry, something went wrong.
IPv6 addresses in Host header (URI), must be enclosed within square brackets, in order to properly separate the host address from any port reference. test: add test for IPv6 hostname conformance in Host header http: Ensure IPv6 is enclosed within square brackets in Host header http: use net.isIPv6 in ClientRequest test: update test with const instead of var test: use common.mustCall and cleanup http: ClientRequest, drop isIPv6() in favor of indexOf() checks http: ClientRequest, replace concatenation with string literal test: use const test: clean-up test: move test to parallel test: skip if no IPv6 support
|
Two failures: 1 is parallel/test-tls-sni-option on smartos, but the arm (p1/p2-raspbian) fails on my test: not ok 61 test-http-host-header-ipv6-fail.js # events.js:154 # throw er; // Unhandled 'error' event # ^ # # Error: listen EAFNOSUPPORT ::1:12346 # at Object.exports._errnoException (util.js:893:11) # at exports._exceptionWithHostPort (util.js:916:20) # at Server._listen2 (net.js:1225:19) # at listen (net.js:1274:10) # at net.js:1384:9 # at _combinedTickCallback (internal/process/next_tick.js:77:11) # at process._tickCallback (internal/process/next_tick.js:98:9) # at Function.Module.runMain (module.js:453:11) # at startup (node.js:155:18) # at node.js:433:3 Apparently it cannot bind ::1 IPv6. Any suggestions? |
Sorry, something went wrong.
|
Updated with IPv6 check, as per nodejs/node-v0.x-archive#7983 |
Sorry, something went wrong.
Sorry, something went wrong.
|
Everything looks green, except a test-dns.js timeout, which is not related to this PR, on p2-raspbian`. Let me know if there's anything else I can do. |
Sorry, something went wrong.
|
LGTM |
Sorry, something went wrong.
IPv6 addresses in Host header (URI), must be enclosed within square brackets, in order to properly separate the host address from any port reference. PR-URL: #5314 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
IPv6 addresses in Host header (URI), must be enclosed within square brackets, in order to properly separate the host address from any port reference. PR-URL: #5314 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
Notable changes: http: * Enclose IPv6 Host header in square brackets. This will enable proper seperation of the host adress from any port reference (Mihai Potra) #5314 path: * Make win32.isAbsolute more consistent (Brian White) #6028 PR-URL: #6060 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Notable changes: http: * Enclose IPv6 Host header in square brackets. This will enable proper seperation of the host adress from any port reference (Mihai Potra) #5314 path: * Make win32.isAbsolute more consistent (Brian White) #6028 PR-URL: #6060 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
IPv6 addresses in Host header (URI), must be enclosed within square brackets, in order to properly separate the host address from any port reference. PR-URL: #5314 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
IPv6 addresses in Host header (URI), must be enclosed within square brackets, in order to properly separate the host address from any port reference. PR-URL: #5314 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
IPv6 addresses in Host header (URI), must be enclosed within square brackets, in order to properly separate the host address from any port reference. PR-URL: #5314 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
IPv6 addresses in Host header (URI), must be enclosed within square brackets, in order to properly separate the host address from any port reference. PR-URL: #5314 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
| Back | FazBrowse Home | New Git URL |
Fixes #5308
As per https://tools.ietf.org/html/rfc7230#section-5.4 and https://tools.ietf.org/html/rfc3986#section-3.2.2 IPv6 addresses in Host header (URI), must be enclosed within square brackets, in order to properly separate the host address from any port reference.