mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 17:01:08 +00:00

Make the `http2` module always available. The `--expose-http2` cli flag is made a non-op PR-URL: https://github.com/nodejs/node/pull/15535 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
28 lines
691 B
JavaScript
Executable File
28 lines
691 B
JavaScript
Executable File
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
const http2 = require('http2');
|
|
|
|
const server = http2.createServer();
|
|
server.setTimeout(common.platformTimeout(1));
|
|
|
|
const onServerTimeout = common.mustCall((session) => {
|
|
session.destroy();
|
|
});
|
|
|
|
server.on('stream', common.mustNotCall());
|
|
server.once('timeout', onServerTimeout);
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
const url = `http://localhost:${server.address().port}`;
|
|
const client = http2.connect(url);
|
|
client.on('close', common.mustCall(() => {
|
|
|
|
const client2 = http2.connect(url);
|
|
client2.on('close', common.mustCall(() => server.close()));
|
|
|
|
}));
|
|
}));
|