summaryrefslogtreecommitdiffhomepage
path: root/src/nodejs
diff options
context:
space:
mode:
Diffstat (limited to 'src/nodejs')
-rw-r--r--src/nodejs/unit-http/binding_pub.gyp25
-rw-r--r--src/nodejs/unit-http/http_server.js16
2 files changed, 36 insertions, 5 deletions
diff --git a/src/nodejs/unit-http/binding_pub.gyp b/src/nodejs/unit-http/binding_pub.gyp
index 3c39933a..3dadf4a5 100644
--- a/src/nodejs/unit-http/binding_pub.gyp
+++ b/src/nodejs/unit-http/binding_pub.gyp
@@ -7,9 +7,28 @@
['OS=="mac"', {
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES'
- }
- }]
- ],
+ },
+ 'conditions': [
+ [ 'target_arch=="arm64"', {
+ 'include_dirs': [
+ '/opt/homebrew/include'
+ ],
+ 'libraries' : [
+ '-L/opt/homebrew/lib',
+ '-lunit'
+ ],
+ }],
+ ['target_arch=="x64"', {
+ 'include_dirs': [
+ '/usr/local/include',
+ ],
+ 'libraries' : [
+ '-L/usr/local/lib',
+ '-lunit'
+ ],
+ }]
+ ]}
+ ]],
'sources': ["unit.cpp", "addon.cpp"],
'libraries': ["-lunit"]
}]
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') {