1'use strict'; 2 3const common = require('../common'); 4if (!common.hasCrypto) 5 common.skip('missing crypto'); 6const http2 = require('http2'); 7 8const msecs = common.platformTimeout(1); 9const server = http2.createServer(); 10 11server.on('request', (req, res) => { 12 res.setTimeout(msecs, common.mustCall(() => { 13 res.end(); 14 })); 15 res.on('timeout', common.mustCall()); 16 res.on('finish', common.mustCall(() => { 17 res.setTimeout(msecs, common.mustNotCall()); 18 process.nextTick(() => { 19 res.setTimeout(msecs, common.mustNotCall()); 20 server.close(); 21 }); 22 })); 23}); 24 25server.listen(0, common.mustCall(() => { 26 const port = server.address().port; 27 const client = http2.connect(`http://localhost:${port}`); 28 const req = client.request({ 29 ':path': '/', 30 ':method': 'GET', 31 ':scheme': 'http', 32 ':authority': `localhost:${port}` 33 }); 34 req.on('end', common.mustCall(() => { 35 client.close(); 36 })); 37 req.resume(); 38 req.end(); 39})); 40