1'use strict'; 2 3const common = require('../common'); 4if (!common.hasCrypto) 5 common.skip('missing crypto'); 6const { Readable, pipeline } = require('stream'); 7const http2 = require('http2'); 8 9{ 10 const server = http2.createServer((req, res) => { 11 pipeline(req, res, common.mustCall()); 12 }); 13 14 server.listen(0, () => { 15 const url = `http://localhost:${server.address().port}`; 16 const client = http2.connect(url); 17 const req = client.request({ ':method': 'POST' }); 18 19 const rs = new Readable({ 20 read() { 21 rs.push('hello'); 22 } 23 }); 24 25 pipeline(rs, req, common.mustCall((err) => { 26 server.close(); 27 client.close(); 28 })); 29 30 let cnt = 10; 31 req.on('data', (data) => { 32 cnt--; 33 if (cnt === 0) rs.destroy(); 34 }); 35 }); 36} 37