1'use strict'; 2const common = require('../common'); 3if (!common.hasCrypto) 4 common.skip('missing crypto'); 5const fixtures = require('../common/fixtures'); 6const http2 = require('http2'); 7 8// This test will result in a crash due to a missed CHECK in C++ or 9// a straight-up segfault if the C++ doesn't send RST_STREAM through 10// properly when calling destroy. 11 12const content = Buffer.alloc(60000, 0x44); 13 14const server = http2.createSecureServer({ 15 key: fixtures.readKey('agent1-key.pem'), 16 cert: fixtures.readKey('agent1-cert.pem') 17}); 18server.on('stream', common.mustCall((stream) => { 19 stream.respond({ 20 'Content-Type': 'application/octet-stream', 21 'Content-Length': (content.length.toString() * 2), 22 'Vary': 'Accept-Encoding' 23 }, { waitForTrailers: true }); 24 25 stream.write(content); 26 stream.destroy(); 27})); 28 29server.listen(0, common.mustCall(() => { 30 const client = http2.connect(`https://localhost:${server.address().port}`, 31 { rejectUnauthorized: false }); 32 33 const req = client.request({ ':path': '/' }); 34 req.end(); 35 req.resume(); // Otherwise close won't be emitted if there's pending data. 36 37 req.on('close', common.mustCall(() => { 38 client.close(); 39 server.close(); 40 })); 41})); 42