errors: alter ERR_HTTP2_INVALID_CONNECTION_HEADERS

changes the base instance for ERR_HTTP2_INVALID_CONNECTION_HEADERS
from Error to TypeError as a more accurate representation
of the error.

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
davidmarkclements 2018-04-04 19:59:00 +02:00 committed by Ruben Bridgewater
parent 019a2c4f84
commit a37e267d21
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762
3 changed files with 5 additions and 4 deletions

View File

@ -728,15 +728,12 @@ E('ERR_HTTP2_GOAWAY_SESSION',
E('ERR_HTTP2_HEADERS_AFTER_RESPOND', E('ERR_HTTP2_HEADERS_AFTER_RESPOND',
'Cannot specify additional headers after response initiated', Error); 'Cannot specify additional headers after response initiated', Error);
E('ERR_HTTP2_HEADERS_SENT', 'Response has already been initiated.', Error); E('ERR_HTTP2_HEADERS_SENT', 'Response has already been initiated.', Error);
E('ERR_HTTP2_HEADER_SINGLE_VALUE', E('ERR_HTTP2_HEADER_SINGLE_VALUE',
'Header field "%s" must only have a single value', TypeError); 'Header field "%s" must only have a single value', TypeError);
E('ERR_HTTP2_INFO_STATUS_NOT_ALLOWED', E('ERR_HTTP2_INFO_STATUS_NOT_ALLOWED',
'Informational status codes cannot be used', RangeError); 'Informational status codes cannot be used', RangeError);
// This should probably be a `TypeError`.
E('ERR_HTTP2_INVALID_CONNECTION_HEADERS', 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', E('ERR_HTTP2_INVALID_HEADER_VALUE',
'Invalid value "%s" for header "%s"', TypeError); 'Invalid value "%s" for header "%s"', TypeError);
E('ERR_HTTP2_INVALID_INFO_STATUS', E('ERR_HTTP2_INVALID_INFO_STATUS',

View File

@ -31,6 +31,7 @@ server.on('stream', common.mustCall((stream, headers) => {
() => stream.pushStream({ 'connection': 'test' }, {}, () => {}), () => stream.pushStream({ 'connection': 'test' }, {}, () => {}),
{ {
code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS', code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS',
name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]',
message: 'HTTP/1 Connection specific headers are forbidden: "connection"' message: 'HTTP/1 Connection specific headers are forbidden: "connection"'
} }
); );

View File

@ -283,6 +283,7 @@ const {
].forEach((name) => { ].forEach((name) => {
common.expectsError({ common.expectsError({
code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS', code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS',
name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]',
message: 'HTTP/1 Connection specific headers are forbidden: ' + message: 'HTTP/1 Connection specific headers are forbidden: ' +
`"${name.toLowerCase()}"` `"${name.toLowerCase()}"`
})(mapToHeaders({ [name]: 'abc' })); })(mapToHeaders({ [name]: 'abc' }));
@ -290,12 +291,14 @@ const {
common.expectsError({ common.expectsError({
code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS', code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS',
name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]',
message: 'HTTP/1 Connection specific headers are forbidden: ' + message: 'HTTP/1 Connection specific headers are forbidden: ' +
`"${HTTP2_HEADER_TE}"` `"${HTTP2_HEADER_TE}"`
})(mapToHeaders({ [HTTP2_HEADER_TE]: ['abc'] })); })(mapToHeaders({ [HTTP2_HEADER_TE]: ['abc'] }));
common.expectsError({ common.expectsError({
code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS', code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS',
name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]',
message: 'HTTP/1 Connection specific headers are forbidden: ' + message: 'HTTP/1 Connection specific headers are forbidden: ' +
`"${HTTP2_HEADER_TE}"` `"${HTTP2_HEADER_TE}"`
})(mapToHeaders({ [HTTP2_HEADER_TE]: ['abc', 'trailers'] })); })(mapToHeaders({ [HTTP2_HEADER_TE]: ['abc', 'trailers'] }));