1'use strict'; 2 3const common = require('../common'); 4if (!common.hasCrypto) 5 common.skip('missing crypto'); 6const http2 = require('http2'); 7const assert = require('assert'); 8const { 9 NGHTTP2_ENHANCE_YOUR_CALM 10} = http2.constants; 11 12for (const prototype of ['maxHeaderListSize', 'maxHeaderSize']) { 13 const server = http2.createServer({ settings: { [prototype]: 100 } }); 14 server.on('stream', common.mustNotCall()); 15 16 server.listen(0, common.mustCall(() => { 17 const client = http2.connect(`http://localhost:${server.address().port}`); 18 19 client.on('remoteSettings', () => { 20 const req = client.request({ 'foo': 'a'.repeat(1000) }); 21 req.on('error', common.expectsError({ 22 code: 'ERR_HTTP2_STREAM_ERROR', 23 name: 'Error', 24 message: 'Stream closed with error code NGHTTP2_ENHANCE_YOUR_CALM' 25 })); 26 req.on('close', common.mustCall(() => { 27 assert.strictEqual(req.rstCode, NGHTTP2_ENHANCE_YOUR_CALM); 28 server.close(); 29 client.close(); 30 })); 31 }); 32 33 })); 34} 35