| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f0f31d0 commit 519850f
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -948,7 +948,7 @@ class Http2Session extends EventEmitter { | |||
| 948 | 948 | if (typeof id !== 'number') | |
| 949 | 949 | throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'id', 'number'); | |
| 950 | 950 | if (id <= 0 || id > kMaxStreams) | |
| 951 | - throw new errors.RangeError('ERR_OUT_OF_RANGE'); | ||
| 951 | + throw new errors.RangeError('ERR_OUT_OF_RANGE', 'id'); | ||
| 952 | 952 | this[kHandle].setNextStreamID(id); | |
| 953 | 953 | } | |
| 954 | 954 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,58 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + if (!common.hasCrypto) | ||
| 5 | + common.skip('missing crypto'); | ||
| 6 | + | ||
| 7 | + const http2 = require('http2'); | ||
| 8 | + | ||
| 9 | + const server = http2.createServer(); | ||
| 10 | + server.on('stream', (stream) => { | ||
| 11 | + stream.respond(); | ||
| 12 | + stream.end('ok'); | ||
| 13 | + }); | ||
| 14 | + | ||
| 15 | + const types = { | ||
| 16 | + boolean: true, | ||
| 17 | + function: () => {}, | ||
| 18 | + number: 1, | ||
| 19 | + object: {}, | ||
| 20 | + array: [], | ||
| 21 | + null: null, | ||
| 22 | + symbol: Symbol('test') | ||
| 23 | + }; | ||
| 24 | + | ||
| 25 | + server.listen(0, common.mustCall(() => { | ||
| 26 | + const client = http2.connect(`http://localhost:${server.address().port}`); | ||
| 27 | + | ||
| 28 | + client.on('connect', () => { | ||
| 29 | + const outOfRangeNum = 2 ** 31; | ||
| 30 | + common.expectsError( | ||
| 31 | + () => client.setNextStreamID(outOfRangeNum), | ||
| 32 | + { | ||
| 33 | + type: RangeError, | ||
| 34 | + code: 'ERR_OUT_OF_RANGE', | ||
| 35 | + message: 'The "id" argument is out of range' | ||
| 36 | + } | ||
| 37 | + ); | ||
| 38 | + | ||
| 39 | + // should throw if something other than number is passed to setNextStreamID | ||
| 40 | + Object.entries(types).forEach(([type, value]) => { | ||
| 41 | + if (type === 'number') { | ||
| 42 | + return; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + common.expectsError( | ||
| 46 | + () => client.setNextStreamID(value), | ||
| 47 | + { | ||
| 48 | + type: TypeError, | ||
| 49 | + code: 'ERR_INVALID_ARG_TYPE', | ||
| 50 | + message: 'The "id" argument must be of type number' | ||
| 51 | + } | ||
| 52 | + ); | ||
| 53 | + }); | ||
| 54 | + | ||
| 55 | + server.close(); | ||
| 56 | + client.close(); | ||
| 57 | + }); | ||
| 58 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments