Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] http2: client throws when receiving header exceeding the max limit #41581

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions test/parallel/test-http2-server-too-large-headers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'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,
// NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE
} = http2.constants;

for (const headerSize of [
DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE - 101, // pass
DEFAULT_SETTINGS_MAX_HEADER_LIST_SIZE - 100, // fail
]) {
const timeout = common.platformTimeout(50);
const timer = setTimeout(() => assert.fail(`http2 client timedout when receiving a header of size ${headerSize}`), timeout);

const server = http2.createServer((req, res) => {
res.setHeader('foobar', 'a'.repeat(headerSize));
res.end(common.mustCall());
});
server.on('error', common.mustNotCall());

server.listen(0, common.mustCall(() => {
const client = http2.connect(`http://localhost:${server.address().port}`);

client.on('remoteSettings', () => {
const req = client.request({ ':path': '/' });
// TODO, I don't yet know which error to expect
// req.on('error',
// (error) => common.expectsError({
// code: 'ERR_HTTP2_STREAM_ERROR',
// name: 'Error',
// message:
// 'Stream closed with error code NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE'
// }));
req.on('close', common.mustCall(() => {
clearTimeout(timer);
// TODO, I don't yet know which error code to expect
// assert.strictEqual(
// req.rstCode,
// NGHTTP2_SETTINGS_MAX_HEADER_LIST_SIZE
// );
server.close();
client.close();
}));
});
}));
}