This also notably changes error handling for request(). Previously some invalid header values (but not all) would cause the session to be unnecessarily destroyed automatically, e.g. passing an unparseable header name to request(). This is no longer the case: header validation failures will throw an error, but will not destroy the session or emit 'error' events. PR-URL: https://github.com/nodejs/node/pull/57917 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
25 lines
789 B
JavaScript
25 lines
789 B
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
|
|
// Tests the assertValidPseudoHeader function that is used within the
|
|
// buildNgHeaderString function. The assert function is not exported so we
|
|
// have to test it through buildNgHeaderString
|
|
|
|
const { buildNgHeaderString } = require('internal/http2/util');
|
|
|
|
// These should not throw
|
|
buildNgHeaderString({ ':status': 'a' });
|
|
buildNgHeaderString({ ':path': 'a' });
|
|
buildNgHeaderString({ ':authority': 'a' });
|
|
buildNgHeaderString({ ':scheme': 'a' });
|
|
buildNgHeaderString({ ':method': 'a' });
|
|
|
|
assert.throws(() => buildNgHeaderString({ ':foo': 'a' }), {
|
|
code: 'ERR_HTTP2_INVALID_PSEUDOHEADER',
|
|
name: 'TypeError',
|
|
message: '":foo" is an invalid pseudoheader or is used incorrectly'
|
|
});
|