From 03ad516b1ea0c9f6e34b69d5f3c64d77db915a4f Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Fri, 30 Jun 2023 12:31:24 +0200 Subject: [PATCH] http: null the joinDuplicateHeaders property on cleanup Null the `joinDuplicateHeaders` property when the parser is freed. Refs: https://github.com/nodejs/node/pull/45982 --- lib/_http_common.js | 1 + test/parallel/test-http-parser-memory-retention.js | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/_http_common.js b/lib/_http_common.js index ebd89049927cef..2c7866d350eea2 100644 --- a/lib/_http_common.js +++ b/lib/_http_common.js @@ -236,6 +236,7 @@ function cleanParser(parser) { parser[kOnTimeout] = null; parser._consumed = false; parser.onIncoming = null; + parser.joinDuplicateHeaders = null; } function prepareError(err, parser, rawPacket) { diff --git a/test/parallel/test-http-parser-memory-retention.js b/test/parallel/test-http-parser-memory-retention.js index 3a6d34221e0bda..316797fec3eaaf 100644 --- a/test/parallel/test-http-parser-memory-retention.js +++ b/test/parallel/test-http-parser-memory-retention.js @@ -25,18 +25,24 @@ server.on('request', common.mustCall((request, response) => { })); server.listen(common.mustCall(() => { - const request = http.get({ port: server.address().port }); + const request = http.get({ + headers: { Connection: 'close' }, + port: server.address().port, + joinDuplicateHeaders: true + }); let parser; request.on('socket', common.mustCall(() => { parser = request.parser; assert.strictEqual(typeof parser.onIncoming, 'function'); + assert.strictEqual(parser.joinDuplicateHeaders, true); })); request.on('response', common.mustCall((response) => { response.resume(); response.on('end', common.mustCall(() => { assert.strictEqual(parser.onIncoming, null); + assert.strictEqual(parser.joinDuplicateHeaders, null); })); })); }));