diff options
author | Andrei Zeliankou <zelenkov@nginx.com> | 2023-09-26 12:49:39 +0100 |
---|---|---|
committer | Andrei Zeliankou <zelenkov@nginx.com> | 2023-09-26 12:49:39 +0100 |
commit | e0c26757740fa7974af6e6592e35b5f2e00339fe (patch) | |
tree | 78651c9a5c94ced2a57c12f03ffa97ffe6e73ed4 /src | |
parent | 0f630c3f604e76de370529907b51ad29dfdc4ecb (diff) | |
download | unit-e0c26757740fa7974af6e6592e35b5f2e00339fe.tar.gz unit-e0c26757740fa7974af6e6592e35b5f2e00339fe.tar.bz2 |
Node.js: response body chunk can now be a Uint8Array.
Starting from Node.js 15.0.0 the chunk parameter of the response.write()
can be a Uint8Array.
This closes #870 issue on GitHub.
Diffstat (limited to 'src')
-rw-r--r-- | src/nodejs/unit-http/http_server.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/nodejs/unit-http/http_server.js b/src/nodejs/unit-http/http_server.js index 89964ec3..11651ed7 100644 --- a/src/nodejs/unit-http/http_server.js +++ b/src/nodejs/unit-http/http_server.js @@ -243,8 +243,11 @@ ServerResponse.prototype._writeBody = function(chunk, encoding, callback) { } if (chunk) { - if (typeof chunk !== 'string' && !(chunk instanceof Buffer)) { - throw new TypeError('First argument must be a string or Buffer'); + if (typeof chunk !== 'string' && !(chunk instanceof Buffer || + chunk instanceof Uint8Array)) { + throw new TypeError( + 'First argument must be a string, Buffer, ' + + 'or Uint8Array'); } if (typeof chunk === 'string') { |