mirror of
https://github.com/nodejs/node.git
synced 2025-05-04 16:42:07 +00:00

changes the base instance for ERR_HTTP2_INVALID_PSEUDOHEADER from Error to TypeError as a more accurate representation of the error. PR-URL: https://github.com/nodejs/node/pull/19808 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
32 lines
889 B
JavaScript
32 lines
889 B
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
// Tests the assertValidPseudoHeader function that is used within the
|
|
// mapToHeaders function. The assert function is not exported so we
|
|
// have to test it through mapToHeaders
|
|
|
|
const { mapToHeaders } = require('internal/http2/util');
|
|
const assert = require('assert');
|
|
|
|
function isNotError(val) {
|
|
assert(!(val instanceof Error));
|
|
}
|
|
|
|
function isError(val) {
|
|
common.expectsError({
|
|
code: 'ERR_HTTP2_INVALID_PSEUDOHEADER',
|
|
type: TypeError,
|
|
message: '":foo" is an invalid pseudoheader or is used incorrectly'
|
|
})(val);
|
|
}
|
|
|
|
isNotError(mapToHeaders({ ':status': 'a' }));
|
|
isNotError(mapToHeaders({ ':path': 'a' }));
|
|
isNotError(mapToHeaders({ ':authority': 'a' }));
|
|
isNotError(mapToHeaders({ ':scheme': 'a' }));
|
|
isNotError(mapToHeaders({ ':method': 'a' }));
|
|
|
|
isError(mapToHeaders({ ':foo': 'a' }));
|