Skip to content

Commit b6fbe16

Browse files
davidmarkclementsjasnell
authored andcommitted
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: #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>
1 parent fbf9e06 commit b6fbe16

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

lib/internal/errors.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -728,15 +728,12 @@ E('ERR_HTTP2_GOAWAY_SESSION',
728728
E('ERR_HTTP2_HEADERS_AFTER_RESPOND',
729729
'Cannot specify additional headers after response initiated', Error);
730730
E('ERR_HTTP2_HEADERS_SENT', 'Response has already been initiated.', Error);
731-
732731
E('ERR_HTTP2_HEADER_SINGLE_VALUE',
733732
'Header field "%s" must only have a single value', TypeError);
734733
E('ERR_HTTP2_INFO_STATUS_NOT_ALLOWED',
735734
'Informational status codes cannot be used', RangeError);
736-
737-
// This should probably be a `TypeError`.
738735
E('ERR_HTTP2_INVALID_CONNECTION_HEADERS',
739-
'HTTP/1 Connection specific headers are forbidden: "%s"', Error);
736+
'HTTP/1 Connection specific headers are forbidden: "%s"', TypeError);
740737
E('ERR_HTTP2_INVALID_HEADER_VALUE',
741738
'Invalid value "%s" for header "%s"', TypeError);
742739
E('ERR_HTTP2_INVALID_INFO_STATUS',

test/parallel/test-http2-server-push-stream-errors-args.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ server.on('stream', common.mustCall((stream, headers) => {
3131
() => stream.pushStream({ 'connection': 'test' }, {}, () => {}),
3232
{
3333
code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS',
34+
name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]',
3435
message: 'HTTP/1 Connection specific headers are forbidden: "connection"'
3536
}
3637
);

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,19 +283,22 @@ const {
283283
].forEach((name) => {
284284
common.expectsError({
285285
code: 'ERR_HTTP2_INVALID_CONNECTION_HEADERS',
286+
name: 'TypeError [ERR_HTTP2_INVALID_CONNECTION_HEADERS]',
286287
message: 'HTTP/1 Connection specific headers are forbidden: ' +
287288
`"${name.toLowerCase()}"`
288289
})(mapToHeaders({ [name]: 'abc' }));
289290
});
290291

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

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

0 commit comments

Comments
 (0)