diff --git a/src/handlers/clientErrorHandler.js b/src/handlers/clientErrorHandler.js index f21fc99..6edf512 100644 --- a/src/handlers/clientErrorHandler.js +++ b/src/handlers/clientErrorHandler.js @@ -7,13 +7,13 @@ const generateServerString = require("../utils/generateServerString.js"); let serverconsole = {}; function clientErrorHandler(err, socket) { - const config = Object.assign(process.serverConfig); + const config = Object.assign({}, process.serverConfig); config.generateServerString = () => generateServerString(config.exposeServerVersion); // getCustomHeaders() in SVR.JS 3.x - config.getCustomHeaders = () => Object.assign(config.customHeaders); + config.getCustomHeaders = () => Object.assign({}, config.customHeaders); // Prevent multiple error handlers from one request if (socket.__assigned__) { @@ -54,7 +54,7 @@ function clientErrorHandler(err, socket) { if (code >= 400 && code <= 499) process.err4xxcounter++; if (code >= 500 && code <= 599) process.err5xxcounter++; let head = "HTTP/1.1 " + code.toString() + " " + name + "\r\n"; - headers = Object.assign(headers); + headers = Object.assign({}, headers); headers["Date"] = new Date().toGMTString(); headers["Connection"] = "close"; Object.keys(headers).forEach(function (headername) { diff --git a/src/handlers/noproxyHandler.js b/src/handlers/noproxyHandler.js index 76e3916..8ab7b46 100644 --- a/src/handlers/noproxyHandler.js +++ b/src/handlers/noproxyHandler.js @@ -27,7 +27,7 @@ function noproxyHandler(req, socket, head) { socket.on("error", () => {}); // SVR.JS configuration object (modified) - const config = Object.assign(process.serverConfig); + const config = Object.assign({}, process.serverConfig); var reqip = socket.remoteAddress; var reqport = socket.remotePort; diff --git a/src/handlers/proxyHandler.js b/src/handlers/proxyHandler.js index c6a8f04..7b76684 100644 --- a/src/handlers/proxyHandler.js +++ b/src/handlers/proxyHandler.js @@ -29,7 +29,7 @@ function proxyHandler(req, socket, head) { socket.on("error", () => {}); // SVR.JS configuration object (modified) - const config = Object.assign(process.serverConfig); + const config = Object.assign({}, process.serverConfig); config.generateServerString = () => { return generateServerString(config.exposeServerVersion); diff --git a/src/handlers/requestHandler.js b/src/handlers/requestHandler.js index 04bda74..da48d0c 100644 --- a/src/handlers/requestHandler.js +++ b/src/handlers/requestHandler.js @@ -29,7 +29,7 @@ function requestHandler(req, res) { }; // SVR.JS configuration object (modified) - const config = Object.assign(process.serverConfig); + const config = Object.assign({}, process.serverConfig); config.generateServerString = () => { return generateServerString(config.exposeServerVersion); @@ -37,7 +37,7 @@ function requestHandler(req, res) { // getCustomHeaders() in SVR.JS 3.x config.getCustomHeaders = () => { - let ph = Object.assign(config.customHeaders); + let ph = Object.assign({}, config.customHeaders); if (config.customHeadersVHost) { let vhostP = null; config.customHeadersVHost.every(function (vhost) { @@ -52,7 +52,7 @@ function requestHandler(req, res) { } }); if (vhostP && vhostP.headers) { - const phNu = Object.assign(vhostP.headers); + const phNu = Object.assign({}, vhostP.headers); Object.keys(phNu).forEach(function (phNuK) { ph[phNuK] = phNu[phNuK]; }); @@ -80,7 +80,7 @@ function requestHandler(req, res) { if (typeof b == "object") table = b; if (table == undefined) table = this.tHeaders; if (table == undefined) table = {}; - table = Object.assign(table); + table = Object.assign({}, table); Object.keys(table).forEach(function (key) { const al = key.toLowerCase(); if ( diff --git a/src/utils/clusterBunShim.js b/src/utils/clusterBunShim.js index 2db690b..c85f3c4 100644 --- a/src/utils/clusterBunShim.js +++ b/src/utils/clusterBunShim.js @@ -87,9 +87,9 @@ if (!process.singleThreaded) { cluster.workers = {}; cluster.fork = function (env) { const child_process = require("child_process"); - let newEnvironment = Object.assign(env ? env : process.env); + let newEnvironment = Object.assign({}, env ? env : process.env); newEnvironment.NODE_UNIQUE_ID = cluster._workersCounter; - let newArguments = Object.assign(process.argv); + let newArguments = Object.assign({}, process.argv); let command = newArguments.shift(); let newWorker = child_process.spawn(command, newArguments, { env: newEnvironment,