2023-03-30 12:40:45 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
if (!common.hasCrypto)
|
|
|
|
common.skip('missing crypto');
|
|
|
|
const http2 = require('http2');
|
|
|
|
const assert = require('assert');
|
|
|
|
const {
|
|
|
|
DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE,
|
2023-10-20 13:28:18 +00:00
|
|
|
NGHTTP2_FRAME_SIZE_ERROR,
|
2023-03-30 12:40:45 +00:00
|
|
|
} = http2.constants;
|
|
|
|
|
|
|
|
const headerSize = DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE;
|
|
|
|
const timeout = common.platformTimeout(2_000);
|
|
|
|
const timer = setTimeout(() => assert.fail(`http2 client timedout
|
|
|
|
when server can not manage to send a header of size ${headerSize}`), timeout);
|
|
|
|
|
|
|
|
const server = http2.createServer((req, res) => {
|
|
|
|
res.setHeader('foobar', 'a'.repeat(DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE));
|
|
|
|
res.end();
|
|
|
|
});
|
|
|
|
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
|
|
const clientSession = http2.connect(`http://localhost:${server.address().port}`);
|
|
|
|
clientSession.on('close', common.mustCall());
|
|
|
|
clientSession.on('remoteSettings', send);
|
|
|
|
|
|
|
|
function send() {
|
|
|
|
const stream = clientSession.request({ ':path': '/' });
|
|
|
|
stream.on('close', common.mustCall(() => {
|
2023-10-20 13:28:18 +00:00
|
|
|
assert.strictEqual(stream.rstCode, NGHTTP2_FRAME_SIZE_ERROR);
|
2023-03-30 12:40:45 +00:00
|
|
|
clearTimeout(timer);
|
|
|
|
server.close();
|
|
|
|
}));
|
|
|
|
|
2023-10-20 13:28:18 +00:00
|
|
|
stream.on('error', common.expectsError({
|
|
|
|
code: 'ERR_HTTP2_STREAM_ERROR',
|
|
|
|
name: 'Error',
|
|
|
|
message: 'Stream closed with error code NGHTTP2_FRAME_SIZE_ERROR'
|
|
|
|
}));
|
|
|
|
|
2023-03-30 12:40:45 +00:00
|
|
|
stream.end();
|
|
|
|
}
|
|
|
|
}));
|