From 9a03c2ab56141f6172cec18a08778e963e879b81 Mon Sep 17 00:00:00 2001 From: Trivikram Kamat Date: Mon, 16 Oct 2017 20:47:38 -0700 Subject: [PATCH] test: http2 util passing array in te header This adds a test case in which array with two values is passed to param value in isIllegalConnectionSpecificHeader Refs: https://github.com/nodejs/node/issues/14985 --- lib/internal/http2/util.js | 3 +-- test/parallel/test-http2-util-headers-list.js | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/internal/http2/util.js b/lib/internal/http2/util.js index baa233e5b0468c..4610be7e4d376e 100644 --- a/lib/internal/http2/util.js +++ b/lib/internal/http2/util.js @@ -360,8 +360,7 @@ function isIllegalConnectionSpecificHeader(name, value) { case HTTP2_HEADER_TRANSFER_ENCODING: return true; case HTTP2_HEADER_TE: - const val = Array.isArray(value) ? value.join(', ') : value; - return val !== 'trailers'; + return value !== 'trailers'; default: return false; } diff --git a/test/parallel/test-http2-util-headers-list.js b/test/parallel/test-http2-util-headers-list.js index 0bc06bb7277b50..1884a22894d280 100644 --- a/test/parallel/test-http2-util-headers-list.js +++ b/test/parallel/test-http2-util-headers-list.js @@ -266,5 +266,10 @@ common.expectsError({ message: regex })(mapToHeaders({ [HTTP2_HEADER_TE]: ['abc'] })); +common.expectsError({ + code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS', + message: regex +})(mapToHeaders({ [HTTP2_HEADER_TE]: ['abc', 'trailers'] })); + assert(!(mapToHeaders({ te: 'trailers' }) instanceof Error)); assert(!(mapToHeaders({ te: ['trailers'] }) instanceof Error));