blob: d7ff08888afb8a8be1f1b861b65741ee99dbbc92 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
'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();
});
});
}
|