Skip to content

Commit eac26c0

Browse files
Trottruyadorno
authored andcommitted
Revert "http: headers(Distinct), trailers(Distinct) setters to be no-op"
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>
1 parent 4c9159a commit eac26c0

File tree

3 files changed

+18
-63
lines changed

3 files changed

+18
-63
lines changed

lib/_http_incoming.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ ObjectDefineProperty(IncomingMessage.prototype, 'headers', {
122122
}
123123
return this[kHeaders];
124124
},
125-
set: function(val) {}
125+
set: function(val) {
126+
this[kHeaders] = val;
127+
}
126128
});
127129

128130
ObjectDefineProperty(IncomingMessage.prototype, 'headersDistinct', {
@@ -140,7 +142,9 @@ ObjectDefineProperty(IncomingMessage.prototype, 'headersDistinct', {
140142
}
141143
return this[kHeadersDistinct];
142144
},
143-
set: function(val) {}
145+
set: function(val) {
146+
this[kHeadersDistinct] = val;
147+
}
144148
});
145149

146150
ObjectDefineProperty(IncomingMessage.prototype, 'trailers', {
@@ -158,7 +162,9 @@ ObjectDefineProperty(IncomingMessage.prototype, 'trailers', {
158162
}
159163
return this[kTrailers];
160164
},
161-
set: function(val) {}
165+
set: function(val) {
166+
this[kTrailers] = val;
167+
}
162168
});
163169

164170
ObjectDefineProperty(IncomingMessage.prototype, 'trailersDistinct', {
@@ -176,7 +182,9 @@ ObjectDefineProperty(IncomingMessage.prototype, 'trailersDistinct', {
176182
}
177183
return this[kTrailersDistinct];
178184
},
179-
set: function(val) {}
185+
set: function(val) {
186+
this[kTrailersDistinct] = val;
187+
}
180188
});
181189

182190
IncomingMessage.prototype.setTimeout = function setTimeout(msecs, callback) {

test/parallel/test-http-set-headers-distinct.js

-54
This file was deleted.

test/parallel/test-set-incoming-message-header.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,24 @@ require('../common');
44
const { IncomingMessage } = require('http');
55
const assert = require('assert');
66

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

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

2121
// _addHeaderLines function set a header correctly
2222
{
2323
const im = new IncomingMessage();
24+
im.headers = { key1: 'value1' };
2425
im._addHeaderLines(['key2', 'value2'], 2);
25-
assert.deepStrictEqual(im.headers, { key2: 'value2' });
26+
assert.deepStrictEqual(im.headers, { key1: 'value1', key2: 'value2' });
2627
}

0 commit comments

Comments
 (0)