Skip to content

Commit 25ef372

Browse files
trivikrMylesBorins
authored andcommitted
http2: simplify te header validation, add test
This simplifies validation of te header and adds a test case in which array with two values is passed to param value in isIllegalConnectionSpecificHeader PR-URL: #16246 Refs: #14985 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
1 parent 6b1f75d commit 25ef372

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/internal/http2/util.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,7 @@ function isIllegalConnectionSpecificHeader(name, value) {
360360
case HTTP2_HEADER_TRANSFER_ENCODING:
361361
return true;
362362
case HTTP2_HEADER_TE:
363-
const val = Array.isArray(value) ? value.join(', ') : value;
364-
return val !== 'trailers';
363+
return value !== 'trailers';
365364
default:
366365
return false;
367366
}

test/parallel/test-http2-util-headers-list.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,5 +266,10 @@ common.expectsError({
266266
message: regex
267267
})(mapToHeaders({ [HTTP2_HEADER_TE]: ['abc'] }));
268268

269+
common.expectsError({
270+
code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS',
271+
message: regex
272+
})(mapToHeaders({ [HTTP2_HEADER_TE]: ['abc', 'trailers'] }));
273+
269274
assert(!(mapToHeaders({ te: 'trailers' }) instanceof Error));
270275
assert(!(mapToHeaders({ te: ['trailers'] }) instanceof Error));

0 commit comments

Comments
 (0)