From 7d8a0b6eb7f4a8eb3e3e2d5aa29a6ea63b29e0d4 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Mon, 3 Jul 2023 08:20:13 +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 PR-URL: https://github.com/nodejs/node/pull/48608 Reviewed-By: Marco Ippolito Reviewed-By: Matteo Collina Reviewed-By: Benjamin Gruenbaum Reviewed-By: Matthew Aitken --- 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); })); })); }));