summaryrefslogtreecommitdiffhomepage
path: root/src/nodejs/unit-http/http_server.js
diff options
context:
space:
mode:
authorIppolitov Igor <iippolitov@nginx.com>2023-10-19 12:50:39 +0100
committerIppolitov Igor <iippolitov@nginx.com>2023-10-19 12:50:39 +0100
commitc43629880472bba8d389dfb0b7ae6d883b0ba499 (patch)
treeacecdcb36cfb85fac3d8cdbfbe473c26ac2e2686 /src/nodejs/unit-http/http_server.js
parent8c4425ccb9a413e8d0506e0254f0e84bd89a32a6 (diff)
parentfb33ec86a3b6ca6a844dfa6980bb9e083094abec (diff)
downloadunit-c43629880472bba8d389dfb0b7ae6d883b0ba499.tar.gz
unit-c43629880472bba8d389dfb0b7ae6d883b0ba499.tar.bz2
Merged with the default branch.1.31.1-1
Diffstat (limited to 'src/nodejs/unit-http/http_server.js')
-rw-r--r--src/nodejs/unit-http/http_server.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/nodejs/unit-http/http_server.js b/src/nodejs/unit-http/http_server.js
index 89964ec3..0f00b47f 100644
--- a/src/nodejs/unit-http/http_server.js
+++ b/src/nodejs/unit-http/http_server.js
@@ -33,8 +33,17 @@ ServerResponse.prototype.statusMessage = undefined;
ServerResponse.prototype.headers_len = 0;
ServerResponse.prototype.headers_count = 0;
ServerResponse.prototype.headersSent = false;
+ServerResponse.prototype.destroyed = false;
ServerResponse.prototype.finished = false;
+ServerResponse.prototype.destroy = function destroy(error) {
+ if (!this.destroyed) {
+ this.destroyed = true;
+ }
+
+ return this;
+};
+
ServerResponse.prototype._finish = function _finish() {
this.headers = {};
this.headers_len = 0;
@@ -243,8 +252,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') {