http2: add support for TypedArray to getUnpackedSettings
This PR is trying to fix the behaviour of http2.getUnpackedSettings
.
$ node --version
v16.0.0-pre
$ node -e "http2.getUnpackedSettings('')"
node:internal/http2/core:3167
throw new ERR_INVALID_ARG_TYPE('buf',
^
TypeError [ERR_INVALID_ARG_TYPE]: The "buf" argument must be an instance of Buffer, TypedArray, or DataView. Received type string ('')
at new NodeError (node:internal/errors:258:15)
at Object.getUnpackedSettings (node:internal/http2/core:3167:11)
at [eval]:1:7
at Script.runInThisContext (node:vm:132:18)
at Object.runInThisContext (node:vm:309:38)
at node:internal/process/execution:77:19
at [eval]-wrapper:6:22
at evalScript (node:internal/process/execution:76:60)
at node:internal/main/eval_string:23:3 {
code: 'ERR_INVALID_ARG_TYPE'
}
$ node -e "http2.getUnpackedSettings(new Uint8Array([0,0,0,0,0,0]))"
node:internal/http2/core:3175
const id = buf.readUInt16BE(offset);
^
TypeError: buf.readUInt16BE is not a function
at Object.getUnpackedSettings (node:internal/http2/core:3175:20)
at [eval]:1:7
at Script.runInThisContext (node:vm:132:18)
at Object.runInThisContext (node:vm:309:38)
at node:internal/process/execution:77:19
at [eval]-wrapper:6:22
at evalScript (node:internal/process/execution:76:60)
at node:internal/main/eval_string:23:3
The error message says we can use TypedArray
, the documentation says we can use Uint8Array
, but in practice only Node.js Buffer
object are accepted.
This PR adds support for all TypedArray
and remove DataView
from the error message. It also updates the documentation.
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
tests and/or benchmarks are included -
documentation is changed or added -
commit message follows commit guidelines