Skip to content

Commit

Permalink
Revert "http: headers(Distinct), trailers(Distinct) setters to be no-op"
Browse files Browse the repository at this point in the history
This reverts commit 4d723c7.

I'm not sure if we should re-apply this as a semver-major change or if
we should accept it as valid and add tests/documentation, but either
way, we have to revert it at least temporarily.

Closes: #45510
PR-URL: #45527
Fixes: #45510
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
  • Loading branch information
Trott authored and ruyadorno committed Nov 24, 2022
1 parent 4c9159a commit eac26c0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 63 deletions.
16 changes: 12 additions & 4 deletions lib/_http_incoming.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ ObjectDefineProperty(IncomingMessage.prototype, 'headers', {
}
return this[kHeaders];
},
set: function(val) {}
set: function(val) {
this[kHeaders] = val;
}
});

ObjectDefineProperty(IncomingMessage.prototype, 'headersDistinct', {
Expand All @@ -140,7 +142,9 @@ ObjectDefineProperty(IncomingMessage.prototype, 'headersDistinct', {
}
return this[kHeadersDistinct];
},
set: function(val) {}
set: function(val) {
this[kHeadersDistinct] = val;
}
});

ObjectDefineProperty(IncomingMessage.prototype, 'trailers', {
Expand All @@ -158,7 +162,9 @@ ObjectDefineProperty(IncomingMessage.prototype, 'trailers', {
}
return this[kTrailers];
},
set: function(val) {}
set: function(val) {
this[kTrailers] = val;
}
});

ObjectDefineProperty(IncomingMessage.prototype, 'trailersDistinct', {
Expand All @@ -176,7 +182,9 @@ ObjectDefineProperty(IncomingMessage.prototype, 'trailersDistinct', {
}
return this[kTrailersDistinct];
},
set: function(val) {}
set: function(val) {
this[kTrailersDistinct] = val;
}
});

IncomingMessage.prototype.setTimeout = function setTimeout(msecs, callback) {
Expand Down
54 changes: 0 additions & 54 deletions test/parallel/test-http-set-headers-distinct.js

This file was deleted.

11 changes: 6 additions & 5 deletions test/parallel/test-set-incoming-message-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,24 @@ require('../common');
const { IncomingMessage } = require('http');
const assert = require('assert');

// Headers setter should be a No-Op
// Headers setter function set a header correctly
{
const im = new IncomingMessage();
im.headers = { key: 'value' };
assert.deepStrictEqual(im.headers, {});
assert.deepStrictEqual(im.headers, { key: 'value' });
}

// Trailers setter should be a No-Op
// Trailers setter function set a header correctly
{
const im = new IncomingMessage();
im.trailers = { key: 'value' };
assert.deepStrictEqual(im.trailers, {});
assert.deepStrictEqual(im.trailers, { key: 'value' });
}

// _addHeaderLines function set a header correctly
{
const im = new IncomingMessage();
im.headers = { key1: 'value1' };
im._addHeaderLines(['key2', 'value2'], 2);
assert.deepStrictEqual(im.headers, { key2: 'value2' });
assert.deepStrictEqual(im.headers, { key1: 'value1', key2: 'value2' });
}

0 comments on commit eac26c0

Please sign in to comment.