diff --git a/lib/internal/http2/util.js b/lib/internal/http2/util.js index fe8542e24f..9441f3e461 100644 --- a/lib/internal/http2/util.js +++ b/lib/internal/http2/util.js @@ -127,8 +127,11 @@ function getStreamState(session, stream) { function isIllegalConnectionSpecificHeader(name, value) { switch (name) { case 'connection': - case 'upgrade': case 'http2-settings': + case 'keep-alive': + case 'proxy-connection': + case 'transfer-encoding': + case 'upgrade': return true; case 'te': return value !== 'trailers'; @@ -154,6 +157,7 @@ function mapToHeaders(map) { var val; if (typeof key === 'symbol' || value === undefined || !key) continue; + key = String(key).toLowerCase(); var isArray = Array.isArray(value); if (key[0] === ':') { if (isArray) { diff --git a/test/parallel/test-http2-util-headers-list.js b/test/parallel/test-http2-util-headers-list.js index 8799353e99..c86c72ec65 100644 --- a/test/parallel/test-http2-util-headers-list.js +++ b/test/parallel/test-http2-util-headers-list.js @@ -98,12 +98,27 @@ assert.throws(() => mapToHeaders({':path': [1, 2, 3]}), message: /^HTTP\/2 pseudo-headers must have a single value$/ })); -['connection', 'upgrade', 'http2-settings', 'te'].forEach((i) => { - assert.throws(() => mapToHeaders({[i]: 'abc'}), - common.expectsError({ - code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS', - message: /^HTTP\/1 Connection specific headers are forbidden$/ - })); -}); +const regex = + /^HTTP\/1 Connection specific headers are forbidden$/; +['connection', + 'upgrade', + 'http2-settings', + 'te', + 'transfer-encoding', + 'proxy-connection', + 'keep-alive', + 'Connection', + 'Upgrade', + 'HTTP2-Settings', + 'TE', + 'Transfer-Encoding', + 'Proxy-Connection', + 'Keep-Alive'].forEach((i) => { + assert.throws(() => mapToHeaders({[i]: 'abc'}), + common.expectsError({ + code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS', + message: regex + }), i); + }); assert.doesNotThrow(() => mapToHeaders({ te: 'trailers' }));