Skip to content

Commit

Permalink
errors: alter ERR_HTTP2_INVALID_CONNECTION_HEADERS
Browse files Browse the repository at this point in the history
changes the base instance for ERR_HTTP2_INVALID_CONNECTION_HEADERS
from Error to TypeError as a more accurate representation
of the error.

PR-URL: nodejs#19807
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
davidmarkclements authored and BridgeAR committed May 1, 2018
1 parent 993b96b commit a0fdfee
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 1 addition & 4 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,15 +566,12 @@ E('ERR_HTTP2_GOAWAY_SESSION',
E('ERR_HTTP2_HEADERS_AFTER_RESPOND',
'Cannot specify additional headers after response initiated', Error);
E('ERR_HTTP2_HEADERS_SENT', 'Response has already been initiated.', Error);

E('ERR_HTTP2_HEADER_SINGLE_VALUE',
'Header field "%s" must only have a single value', TypeError);
E('ERR_HTTP2_INFO_STATUS_NOT_ALLOWED',
'Informational status codes cannot be used', RangeError);

// This should probably be a `TypeError`.
E('ERR_HTTP2_INVALID_CONNECTION_HEADERS',
'HTTP/1 Connection specific headers are forbidden: "%s"', Error);
'HTTP/1 Connection specific headers are forbidden: "%s"', TypeError);
E('ERR_HTTP2_INVALID_HEADER_VALUE',
'Invalid value "%s" for header "%s"', TypeError);
E('ERR_HTTP2_INVALID_INFO_STATUS',
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-http2-server-push-stream-errors-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ server.on('stream', common.mustCall((stream, headers) => {
() => stream.pushStream({ 'connection': 'test' }, {}, () => {}),
{
code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS',
name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]',
message: 'HTTP/1 Connection specific headers are forbidden: "connection"'
}
);
Expand Down
3 changes: 3 additions & 0 deletions test/parallel/test-http2-util-headers-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,19 +283,22 @@ const {
].forEach((name) => {
common.expectsError({
code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS',
name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]',
message: 'HTTP/1 Connection specific headers are forbidden: ' +
`"${name.toLowerCase()}"`
})(mapToHeaders({ [name]: 'abc' }));
});

common.expectsError({
code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS',
name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]',
message: 'HTTP/1 Connection specific headers are forbidden: ' +
`"${HTTP2_HEADER_TE}"`
})(mapToHeaders({ [HTTP2_HEADER_TE]: ['abc'] }));

common.expectsError({
code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS',
name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]',
message: 'HTTP/1 Connection specific headers are forbidden: ' +
`"${HTTP2_HEADER_TE}"`
})(mapToHeaders({ [HTTP2_HEADER_TE]: ['abc', 'trailers'] }));
Expand Down

0 comments on commit a0fdfee

Please sign in to comment.