Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions test/parallel/test-http2-ip-address-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ const key = loadKey('agent8-key.pem');
const cert = fixtures.readKey('agent8-cert.pem');

const server = h2.createSecureServer({ key, cert });
const hasIPv6 = common.hasIPv6;
const testCount = hasIPv6 ? 2 : 1;

server.on('stream', common.mustCall((stream) => {
const session = stream.session;
assert.strictEqual(session.servername, undefined);
Expand All @@ -23,7 +26,7 @@ server.on('stream', common.mustCall((stream) => {
originSet: session.originSet
})
);
}, 2));
}, testCount));

let done = 0;

Expand All @@ -39,12 +42,12 @@ server.listen(0, common.mustCall(() => {
const originSet = req.session.originSet;
assert.strictEqual(originSet[0], url);
client.close();
if (++done === 2) server.close();
if (++done === testCount) server.close();
Copy link
Contributor Author

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.

}));
}

const ipv4Url = `https://127.0.0.1:${server.address().port}`;
const ipv6Url = `https://[::1]:${server.address().port}`;
handleRequest(ipv4Url);
if (common.hasIPv6) handleRequest(ipv6Url);
if (hasIPv6) handleRequest(ipv6Url);
}));
Loading