-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
http2: omit server name when HTTP2 host is IP address #56530
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made some adjustments to process the requests in parallel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this branch because the EADDRNOTAVAIL error was occurring in the tests.
Co-authored-by: Luigi Pinca <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RSLGTM
if (++done === 2) server.close(); | ||
if (++done === testCount) server.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I missed that the number of tests changes if you don't test for IPv6.
Fixes: #56189