1'use strict'; 2const common = require('../common'); 3if (!common.hasCrypto) 4 common.skip('missing crypto'); 5const { readSync } = require('../common/fixtures'); 6const net = require('net'); 7const http2 = require('http2'); 8const { once } = require('events'); 9 10async function main() { 11 const blobWithEmptyFrame = readSync('emptyframe.http2'); 12 const server = net.createServer((socket) => { 13 socket.end(blobWithEmptyFrame); 14 }).listen(0); 15 await once(server, 'listening'); 16 17 for (const maxSessionInvalidFrames of [0, 2]) { 18 const client = http2.connect(`http://localhost:${server.address().port}`, { 19 maxSessionInvalidFrames 20 }); 21 const stream = client.request({ 22 ':method': 'GET', 23 ':path': '/' 24 }); 25 if (maxSessionInvalidFrames) { 26 stream.on('error', common.mustNotCall()); 27 client.on('error', common.mustNotCall()); 28 } else { 29 stream.on('error', common.mustCall()); 30 client.on('error', common.mustCall()); 31 } 32 stream.resume(); 33 await once(stream, 'end'); 34 client.close(); 35 } 36 server.close(); 37} 38 39main().then(common.mustCall()); 40