diff options
Diffstat (limited to 'lib/internal/http2')
-rw-r--r-- | lib/internal/http2/compat.js | 10 | ||||
-rw-r--r-- | lib/internal/http2/core.js | 24 | ||||
-rw-r--r-- | lib/internal/http2/util.js | 2 |
3 files changed, 20 insertions, 16 deletions
diff --git a/lib/internal/http2/compat.js b/lib/internal/http2/compat.js index 6ec6cb33cb..78fedcb2ce 100644 --- a/lib/internal/http2/compat.js +++ b/lib/internal/http2/compat.js @@ -438,7 +438,7 @@ class Http2ServerResponse extends Stream { setTrailer(name, value) { if (typeof name !== 'string') - throw new ERR_INVALID_ARG_TYPE('name', 'string'); + throw new ERR_INVALID_ARG_TYPE('name', 'string', name); name = name.trim().toLowerCase(); assertValidHeader(name, value); @@ -456,7 +456,7 @@ class Http2ServerResponse extends Stream { getHeader(name) { if (typeof name !== 'string') - throw new ERR_INVALID_ARG_TYPE('name', 'string'); + throw new ERR_INVALID_ARG_TYPE('name', 'string', name); name = name.trim().toLowerCase(); return this[kHeaders][name]; @@ -472,7 +472,7 @@ class Http2ServerResponse extends Stream { hasHeader(name) { if (typeof name !== 'string') - throw new ERR_INVALID_ARG_TYPE('name', 'string'); + throw new ERR_INVALID_ARG_TYPE('name', 'string', name); name = name.trim().toLowerCase(); return Object.prototype.hasOwnProperty.call(this[kHeaders], name); @@ -480,7 +480,7 @@ class Http2ServerResponse extends Stream { removeHeader(name) { if (typeof name !== 'string') - throw new ERR_INVALID_ARG_TYPE('name', 'string'); + throw new ERR_INVALID_ARG_TYPE('name', 'string', name); if (this[kStream].headersSent) throw new ERR_HTTP2_HEADERS_SENT(); @@ -491,7 +491,7 @@ class Http2ServerResponse extends Stream { setHeader(name, value) { if (typeof name !== 'string') - throw new ERR_INVALID_ARG_TYPE('name', 'string'); + throw new ERR_INVALID_ARG_TYPE('name', 'string', name); if (this[kStream].headersSent) throw new ERR_HTTP2_HEADERS_SENT(); diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js index 9978df87d6..89cc8db0b0 100644 --- a/lib/internal/http2/core.js +++ b/lib/internal/http2/core.js @@ -984,7 +984,7 @@ class Http2Session extends EventEmitter { throw new ERR_HTTP2_INVALID_SESSION(); if (typeof id !== 'number') - throw new ERR_INVALID_ARG_TYPE('id', 'number'); + throw new ERR_INVALID_ARG_TYPE('id', 'number', id); if (id <= 0 || id > kMaxStreams) throw new ERR_OUT_OF_RANGE('id', `> 0 and <= ${kMaxStreams}`, id); this[kHandle].setNextStreamID(id); @@ -1003,7 +1003,8 @@ class Http2Session extends EventEmitter { } if (payload && !isArrayBufferView(payload)) { throw new ERR_INVALID_ARG_TYPE('payload', - ['Buffer', 'TypedArray', 'DataView']); + ['Buffer', 'TypedArray', 'DataView'], + payload); } if (payload && payload.length !== 8) { throw new ERR_HTTP2_PING_LENGTH(); @@ -1122,13 +1123,14 @@ class Http2Session extends EventEmitter { if (opaqueData !== undefined && !isArrayBufferView(opaqueData)) { throw new ERR_INVALID_ARG_TYPE('opaqueData', - ['Buffer', 'TypedArray', 'DataView']); + ['Buffer', 'TypedArray', 'DataView'], + opaqueData); } if (typeof code !== 'number') { - throw new ERR_INVALID_ARG_TYPE('code', 'number'); + throw new ERR_INVALID_ARG_TYPE('code', 'number', code); } if (typeof lastStreamID !== 'number') { - throw new ERR_INVALID_ARG_TYPE('lastStreamID', 'number'); + throw new ERR_INVALID_ARG_TYPE('lastStreamID', 'number', lastStreamID); } const goawayFn = submitGoaway.bind(this, code, lastStreamID, opaqueData); @@ -1321,14 +1323,15 @@ class ServerHttp2Session extends Http2Session { // be invalid. if (typeof origin !== 'string') { throw new ERR_INVALID_ARG_TYPE('originOrStream', - ['string', 'number', 'URL', 'object']); + ['string', 'number', 'URL', 'object'], + originOrStream); } else if (origin === 'null' || origin.length === 0) { throw new ERR_HTTP2_ALTSVC_INVALID_ORIGIN(); } } if (typeof alt !== 'string') - throw new ERR_INVALID_ARG_TYPE('alt', 'string'); + throw new ERR_INVALID_ARG_TYPE('alt', 'string', alt); if (!kQuotedString.test(alt)) throw new ERR_INVALID_CHAR('alt'); @@ -1794,7 +1797,7 @@ class Http2Stream extends Duplex { // but no DATA and HEADERS frames may be sent. close(code = NGHTTP2_NO_ERROR, callback) { if (typeof code !== 'number') - throw new ERR_INVALID_ARG_TYPE('code', 'number'); + throw new ERR_INVALID_ARG_TYPE('code', 'number', code); if (code < 0 || code > kMaxInt) throw new ERR_OUT_OF_RANGE('code'); if (callback !== undefined && typeof callback !== 'function') @@ -2313,7 +2316,7 @@ class ServerHttp2Stream extends Http2Stream { } if (typeof fd !== 'number') - throw new ERR_INVALID_ARG_TYPE('fd', 'number'); + throw new ERR_INVALID_ARG_TYPE('fd', 'number', fd); debug(`Http2Stream ${this[kID]} [Http2Session ` + `${sessionName(session[kType])}]: initiating response from fd`); @@ -2767,7 +2770,8 @@ function getPackedSettings(settings) { function getUnpackedSettings(buf, options = {}) { if (!isArrayBufferView(buf)) { - throw new ERR_INVALID_ARG_TYPE('buf', ['Buffer', 'TypedArray', 'DataView']); + throw new ERR_INVALID_ARG_TYPE('buf', + ['Buffer', 'TypedArray', 'DataView'], buf); } if (buf.length % 6 !== 0) throw new ERR_HTTP2_INVALID_PACKED_SETTINGS_LENGTH(); diff --git a/lib/internal/http2/util.js b/lib/internal/http2/util.js index b9bd580af2..bf5d072193 100644 --- a/lib/internal/http2/util.js +++ b/lib/internal/http2/util.js @@ -482,7 +482,7 @@ function assertIsObject(value, name, types = 'Object') { (value === null || typeof value !== 'object' || Array.isArray(value))) { - const err = new ERR_INVALID_ARG_TYPE(name, types); + const err = new ERR_INVALID_ARG_TYPE(name, types, value); Error.captureStackTrace(err, assertIsObject); throw err; } |