mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 18:44:40 +00:00

PR-URL: https://github.com/nodejs/node/pull/17328 Fixes: https://github.com/nodejs/node/issues/15303 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Sebastiaan Deckers <sebdeckers83@gmail.com>
40 lines
906 B
JavaScript
40 lines
906 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('close', 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();
|
|
}
|