node/test/parallel/test-http2-endafterheaders.js
geekreal 0d1dfe157e
http: remove useless ternary in test
PR-URL: https://github.com/nodejs/node/pull/48481
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Qingyu Deng <i@ayase-lab.com>
2023-06-22 19:07:36 +00:00

51 lines
1.4 KiB
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const http2 = require('http2');
const Countdown = require('../common/countdown');
const server = http2.createServer();
server.on('stream', common.mustCall((stream, headers) => {
const check = headers[':method'] === 'GET';
assert.strictEqual(stream.endAfterHeaders, check);
stream.on('data', common.mustNotCall());
stream.on('end', common.mustCall());
stream.respond();
stream.end('ok');
}, 2));
const countdown = new Countdown(2, () => server.close());
server.listen(0, common.mustCall(() => {
{
const client = http2.connect(`http://localhost:${server.address().port}`);
const req = client.request();
req.resume();
req.on('response', common.mustCall(() => {
assert.strictEqual(req.endAfterHeaders, false);
}));
req.on('end', common.mustCall(() => {
client.close();
countdown.dec();
}));
}
{
const client = http2.connect(`http://localhost:${server.address().port}`);
const req = client.request({ ':method': 'POST' });
req.resume();
req.end();
req.on('response', common.mustCall(() => {
assert.strictEqual(req.endAfterHeaders, false);
}));
req.on('end', common.mustCall(() => {
client.close();
countdown.dec();
}));
}
}));