summaryrefslogtreecommitdiffhomepage
path: root/src/nodejs/unit-http/http_server.js
diff options
context:
space:
mode:
authorskokalin <sergey.kokalin@gmail.com>2025-05-28 17:47:42 +0400
committerAndrew Clayton <a.clayton@nginx.com>2025-05-28 17:27:04 +0100
commit9ae106730e28f89aed7987d40c9387057df4784e (patch)
tree1bf51918ffbf0a6a13362dd7b86c2142055aecf7 /src/nodejs/unit-http/http_server.js
parent39f9121339559738cba5130c818e8920e1a2fa16 (diff)
downloadunit-9ae106730e28f89aed7987d40c9387057df4784e.tar.gz
unit-9ae106730e28f89aed7987d40c9387057df4784e.tar.bz2
node.js: Fixed issue with duplicate headers in response
It fixes losing context in response in cases when there are 2 or more headers with the same name. The prev implementation used to use foreach function which uses local lexical environment and did not find this.headers_len locally, which causes crash of the http server module. It was replaced with a for loop in order to make access for this.headers_len variable and improve performance of calculation. Closes: https://github.com/nginx/unit/issues/1621 Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to '')
-rw-r--r--src/nodejs/unit-http/http_server.js6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/nodejs/unit-http/http_server.js b/src/nodejs/unit-http/http_server.js
index 4e1c190e..68400b84 100644
--- a/src/nodejs/unit-http/http_server.js
+++ b/src/nodejs/unit-http/http_server.js
@@ -153,9 +153,9 @@ ServerResponse.prototype._removeHeader = function _removeHeader(lc_name) {
this.headers_count -= value.length;
this.headers_len -= value.length * name_len;
- value.forEach(function(val) {
- this.headers_len -= Buffer.byteLength(val + "", 'latin1');
- });
+ for (let i = 0; i < value.length; i++){
+ this.headers_len -= Buffer.byteLength(value[i] + "", 'latin1');
+ }
return;
}