Skip to content

Commit

Permalink
http: null the joinDuplicateHeaders property on cleanup
Browse files Browse the repository at this point in the history
Null the `joinDuplicateHeaders` property when the parser is freed.

Refs: #45982
PR-URL: #48608
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matthew Aitken <maitken033380023@gmail.com>
  • Loading branch information
lpinca authored and ruyadorno committed Sep 11, 2023
1 parent d4518ba commit 27d6833
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/_http_common.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ function cleanParser(parser) {
parser[kOnTimeout] = null;
parser._consumed = false;
parser.onIncoming = null;
parser.joinDuplicateHeaders = null;
}

function prepareError(err, parser, rawPacket) {
Expand Down
8 changes: 7 additions & 1 deletion test/parallel/test-http-parser-memory-retention.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}));
}));
}));

0 comments on commit 27d6833

Please sign in to comment.