mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 16:22:29 +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>
40 lines
913 B
JavaScript
40 lines
913 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
const http2 = require('http2');
|
|
const assert = require('assert');
|
|
|
|
const server = http2.createServer();
|
|
|
|
// Check that stream ends immediately after respond on :status 204, 205 & 304
|
|
|
|
const status = [204, 205, 304];
|
|
|
|
server.on('stream', common.mustCall((stream) => {
|
|
stream.on('streamClosed', common.mustCall(() => {
|
|
assert.strictEqual(stream.destroyed, true);
|
|
}));
|
|
stream.respond({ ':status': status.shift() });
|
|
}, 3));
|
|
|
|
server.listen(0, common.mustCall(makeRequest));
|
|
|
|
function makeRequest() {
|
|
const client = http2.connect(`http://localhost:${server.address().port}`);
|
|
const req = client.request();
|
|
req.resume();
|
|
|
|
req.on('end', common.mustCall(() => {
|
|
client.destroy();
|
|
|
|
if (!status.length) {
|
|
server.close();
|
|
} else {
|
|
makeRequest();
|
|
}
|
|
}));
|
|
req.end();
|
|
}
|