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

Splitting out the http2 portion of the test has a few benfits: * We don't skip the rest of the tests if `node` is compiled without crypto. * We can find out if the http2 portion of the test is responsible for the timeouts reported in issue 24456. Refs: https://github.com/nodejs/node/issues/24456 PR-URL: https://github.com/nodejs/node/pull/24631 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
37 lines
782 B
JavaScript
37 lines
782 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
const { Readable, pipeline } = require('stream');
|
|
const http2 = require('http2');
|
|
|
|
{
|
|
const server = http2.createServer((req, res) => {
|
|
pipeline(req, res, common.mustCall());
|
|
});
|
|
|
|
server.listen(0, () => {
|
|
const url = `http://localhost:${server.address().port}`;
|
|
const client = http2.connect(url);
|
|
const req = client.request({ ':method': 'POST' });
|
|
|
|
const rs = new Readable({
|
|
read() {
|
|
rs.push('hello');
|
|
}
|
|
});
|
|
|
|
pipeline(rs, req, common.mustCall((err) => {
|
|
server.close();
|
|
client.close();
|
|
}));
|
|
|
|
let cnt = 10;
|
|
req.on('data', (data) => {
|
|
cnt--;
|
|
if (cnt === 0) rs.destroy();
|
|
});
|
|
});
|
|
}
|