1'use strict'; 2 3const common = require('../common'); 4if (!common.hasCrypto) 5 common.skip('missing crypto'); 6const assert = require('assert'); 7const h2 = require('http2'); 8 9const server = h2.createServer(); 10 11// We use the lower-level API here 12server.on('stream', common.mustNotCall()); 13server.listen(0, common.mustCall(() => { 14 15 // Setting the maxSendHeaderBlockLength, then attempting to send a 16 // headers block that is too big should cause a 'frameError' to 17 // be emitted, and will cause the stream to be shutdown. 18 const options = { 19 maxSendHeaderBlockLength: 10 20 }; 21 22 const client = h2.connect(`http://localhost:${server.address().port}`, 23 options); 24 25 const req = client.request(); 26 req.on('response', common.mustNotCall()); 27 28 req.resume(); 29 req.on('close', common.mustCall(() => { 30 client.close(); 31 server.close(); 32 })); 33 34 req.on('frameError', common.mustCall((type, code) => { 35 assert.strictEqual(code, h2.constants.NGHTTP2_FRAME_SIZE_ERROR); 36 })); 37 38 req.on('error', common.expectsError({ 39 code: 'ERR_HTTP2_STREAM_ERROR', 40 name: 'Error', 41 message: 'Stream closed with error code NGHTTP2_FRAME_SIZE_ERROR' 42 })); 43})); 44