summaryrefslogtreecommitdiffhomepage
path: root/src/nodejs/unit-http/http_server.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/nodejs/unit-http/http_server.js')
-rwxr-xr-xsrc/nodejs/unit-http/http_server.js17
1 files changed, 5 insertions, 12 deletions
diff --git a/src/nodejs/unit-http/http_server.js b/src/nodejs/unit-http/http_server.js
index 9b7b8403..8a536cde 100755
--- a/src/nodejs/unit-http/http_server.js
+++ b/src/nodejs/unit-http/http_server.js
@@ -342,7 +342,7 @@ Server.prototype.listen = function () {
this.unit.listen();
};
-Server.prototype.run_events = function (server, req, res) {
+Server.prototype.emit_events = function (server, req, res) {
req.server = server;
res.server = server;
req.res = res;
@@ -350,18 +350,11 @@ Server.prototype.run_events = function (server, req, res) {
server.buffer = server.unit._read(req.socket.req_pointer);
- /* Important!!! setImmediate starts the next iteration in Node.js loop. */
- setImmediate(function () {
- server.emit("request", req, res);
+ server.emit("request", req, res);
- Promise.resolve().then(() => {
- req.emit("finish");
- req.emit("end");
-
- if (res.finished) {
- unit_lib.unit_response_end(res);
- }
- });
+ process.nextTick(() => {
+ req.emit("finish");
+ req.emit("end");
});
};