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 12// By default, the maximum number of header fields allowed per 13// block is 128, including the HTTP pseudo-header fields. The 14// minimum value for servers is 4, setting this to any value 15// less than 4 will still leave the minimum to 4. 16const server = http2.createServer({ maxHeaderListPairs: 0 }); 17server.on('stream', common.mustNotCall()); 18 19server.listen(0, common.mustCall(() => { 20 const client = http2.connect(`http://localhost:${server.address().port}`); 21 22 const req = client.request({ foo: 'bar' }); 23 req.on('error', common.expectsError({ 24 code: 'ERR_HTTP2_STREAM_ERROR', 25 name: 'Error', 26 message: 'Stream closed with error code NGHTTP2_ENHANCE_YOUR_CALM' 27 })); 28 req.on('close', common.mustCall(() => { 29 assert.strictEqual(req.rstCode, NGHTTP2_ENHANCE_YOUR_CALM); 30 server.close(); 31 client.close(); 32 })); 33 34})); 35