mirror of
https://github.com/nodejs/node.git
synced 2025-04-29 14:25:18 +00:00

Some checks failed
Coverage Linux (without intl) / coverage-linux-without-intl (push) Waiting to run
Coverage Linux / coverage-linux (push) Waiting to run
Coverage Windows / coverage-windows (push) Waiting to run
Test and upload documentation to artifacts / build-docs (push) Waiting to run
Linters / lint-addon-docs (push) Waiting to run
Linters / lint-cpp (push) Waiting to run
Linters / format-cpp (push) Waiting to run
Linters / lint-js-and-md (push) Waiting to run
Linters / lint-py (push) Waiting to run
Linters / lint-yaml (push) Waiting to run
Linters / lint-sh (push) Waiting to run
Linters / lint-codeowners (push) Waiting to run
Linters / lint-pr-url (push) Waiting to run
Linters / lint-readme (push) Waiting to run
Notify on Push / Notify on Force Push on `main` (push) Waiting to run
Notify on Push / Notify on Push on `main` that lacks metadata (push) Waiting to run
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled
Find inactive TSC voting members / find (push) Has been cancelled
Fixes: https://github.com/nodejs/node/issues/56189 PR-URL: https://github.com/nodejs/node/pull/56530 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto) { common.skip('missing crypto'); };
|
|
const assert = require('assert');
|
|
const fixtures = require('../common/fixtures');
|
|
const h2 = require('http2');
|
|
|
|
function loadKey(keyname) {
|
|
return fixtures.readKey(keyname, 'binary');
|
|
}
|
|
|
|
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);
|
|
stream.respond({ 'content-type': 'application/json' });
|
|
stream.end(JSON.stringify({
|
|
servername: session.servername,
|
|
originSet: session.originSet
|
|
})
|
|
);
|
|
}, testCount));
|
|
|
|
let done = 0;
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
function handleRequest(url) {
|
|
const client = h2.connect(url,
|
|
{ rejectUnauthorized: false });
|
|
const req = client.request();
|
|
let data = '';
|
|
req.setEncoding('utf8');
|
|
req.on('data', (d) => data += d);
|
|
req.on('end', common.mustCall(() => {
|
|
const originSet = req.session.originSet;
|
|
assert.strictEqual(originSet[0], url);
|
|
client.close();
|
|
if (++done === testCount) server.close();
|
|
}));
|
|
}
|
|
|
|
const ipv4Url = `https://127.0.0.1:${server.address().port}`;
|
|
const ipv6Url = `https://[::1]:${server.address().port}`;
|
|
handleRequest(ipv4Url);
|
|
if (hasIPv6) handleRequest(ipv6Url);
|
|
}));
|