http2: omit server name when HTTP2 host is IP address#56530
Conversation
|
Review requested:
|
| let hostName = socket.servername; | ||
| if (hostName === null || hostName === false) { | ||
| if (socket.remoteFamily === 'IPv6') { | ||
| hostName = `[${socket.remoteAddress}]`; | ||
| } else { | ||
| hostName = socket.remoteAddress; | ||
| } |
There was a problem hiding this comment.
Host: the value sent in Server Name Indication (SNI) ([RFC6066],
Section 3) converted to lower case; if SNI is not present, the
remote address of the connection (i.e., the server's IP address)
According to RFC 8336, when the server name is not set, the server's address should be used instead.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #56530 +/- ##
==========================================
+ Coverage 88.54% 89.19% +0.65%
==========================================
Files 657 662 +5
Lines 190689 191808 +1119
Branches 36602 36926 +324
==========================================
+ Hits 168844 171089 +2245
+ Misses 15029 13564 -1465
- Partials 6816 7155 +339
|
| }) | ||
| ); | ||
| }, 2)); | ||
| server.on('close', common.mustCall()); |
There was a problem hiding this comment.
| server.on('close', common.mustCall()); |
| let data = ''; | ||
| req.setEncoding('utf8'); | ||
| req.on('data', (d) => data += d); | ||
| req.on('end', common.mustCall(() => { |
There was a problem hiding this comment.
Can't the requests be done in parallel? Then server can be closed with something in the listeners of 'end' events
if (++done === 2) server.close();There was a problem hiding this comment.
I've made some adjustments to process the requests in parallel.
| const ipv4Url = `https://127.0.0.1:${server.address().port}`; | ||
| const ipv6Url = `https://[::1]:${server.address().port}`; | ||
| handleRequest(ipv4Url); | ||
| if (common.hasIPv6) handleRequest(ipv6Url); |
There was a problem hiding this comment.
I added this branch because the EADDRNOTAVAIL error was occurring in the tests.
Co-authored-by: Luigi Pinca <luigipinca@gmail.com>
| if (++done === 2) server.close(); | ||
| if (++done === testCount) server.close(); |
There was a problem hiding this comment.
Sorry, I missed that the number of tests changes if you don't test for IPv6.
Commit Queue failed- Loading data for nodejs/node/pull/56530 ✔ Done loading data for nodejs/node/pull/56530 ----------------------------------- PR info ------------------------------------ Title http2: omit server name when HTTP2 host is IP address (#56530) ⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch islandryu:fix/http2 -> nodejs:main Labels http2, needs-ci, commit-queue-squash Commits 4 - http2: omit server name when HTTP2 host is IP address - fix test - Update test/parallel/test-http2-ip-address-host.js - fix test Committers 2 - islandryu <shimaryuhei@gmail.com> - GitHub <noreply@github.com> PR-URL: https://github.com/nodejs/node/pull/56530 Fixes: https://github.com/nodejs/node/issues/56189 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/56530 Fixes: https://github.com/nodejs/node/issues/56189 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> -------------------------------------------------------------------------------- ⚠ Commits were pushed since the last approving review: ⚠ - fix test ℹ This PR was created on Thu, 09 Jan 2025 08:41:18 GMT ✔ Approvals: 3 ✔ - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/56530#pullrequestreview-2546485278 ✔ - Yongsheng Zhang (@ZYSzys): https://github.com/nodejs/node/pull/56530#pullrequestreview-2548929308 ✔ - Luigi Pinca (@lpinca): https://github.com/nodejs/node/pull/56530#pullrequestreview-2548972673 ✔ Last GitHub CI successful ℹ Last Full PR CI on 2025-01-14T13:02:02Z: https://ci.nodejs.org/job/node-test-pull-request/64501/ - Querying data for job/node-test-pull-request/64501/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/12846830944 |
|
Landed in fdad2fa |
Fixes: #56189