Skip to content

Commit

Permalink
http2: simplify te header validation, add test
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
trivikr authored and MylesBorins committed Oct 23, 2017
1 parent 6b1f75d commit 25ef372
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/internal/http2/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 5 additions & 0 deletions test/parallel/test-http2-util-headers-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));

0 comments on commit 25ef372

Please sign in to comment.