Revert "http: headers(Distinct), trailers(Distinct) setters to be no-op"
This reverts commit 4d723c7fd6f8b2ecd0dbc1d6f0595645f6471928. 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: https://github.com/nodejs/node/issues/45510 PR-URL: https://github.com/nodejs/node/pull/45527 Fixes: https://github.com/nodejs/node/issues/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>
This commit is contained in:
parent
367ac71894
commit
6a84f1c403
@ -122,7 +122,9 @@ ObjectDefineProperty(IncomingMessage.prototype, 'headers', {
|
||||
}
|
||||
return this[kHeaders];
|
||||
},
|
||||
set: function(val) {}
|
||||
set: function(val) {
|
||||
this[kHeaders] = val;
|
||||
}
|
||||
});
|
||||
|
||||
ObjectDefineProperty(IncomingMessage.prototype, 'headersDistinct', {
|
||||
@ -140,7 +142,9 @@ ObjectDefineProperty(IncomingMessage.prototype, 'headersDistinct', {
|
||||
}
|
||||
return this[kHeadersDistinct];
|
||||
},
|
||||
set: function(val) {}
|
||||
set: function(val) {
|
||||
this[kHeadersDistinct] = val;
|
||||
}
|
||||
});
|
||||
|
||||
ObjectDefineProperty(IncomingMessage.prototype, 'trailers', {
|
||||
@ -158,7 +162,9 @@ ObjectDefineProperty(IncomingMessage.prototype, 'trailers', {
|
||||
}
|
||||
return this[kTrailers];
|
||||
},
|
||||
set: function(val) {}
|
||||
set: function(val) {
|
||||
this[kTrailers] = val;
|
||||
}
|
||||
});
|
||||
|
||||
ObjectDefineProperty(IncomingMessage.prototype, 'trailersDistinct', {
|
||||
@ -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) {
|
||||
|
@ -1,54 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const { createServer, request } = require('http');
|
||||
|
||||
const server = createServer(
|
||||
common.mustCall((req, res) => {
|
||||
req.headersDistinct = { 'x-req-a': ['zzz'] };
|
||||
|
||||
// headersDistinct setter should be a No-Op
|
||||
assert.deepStrictEqual(req.headersDistinct, {
|
||||
'transfer-encoding': [
|
||||
'chunked',
|
||||
],
|
||||
'connection': [
|
||||
'keep-alive',
|
||||
],
|
||||
'host': [
|
||||
`127.0.0.1:${server.address().port}`,
|
||||
]
|
||||
});
|
||||
|
||||
req.on('end', function() {
|
||||
res.write('BODY');
|
||||
res.end();
|
||||
});
|
||||
|
||||
req.resume();
|
||||
})
|
||||
);
|
||||
|
||||
server.listen(
|
||||
0,
|
||||
common.mustCall(() => {
|
||||
const req = request(
|
||||
{
|
||||
host: '127.0.0.1',
|
||||
port: server.address().port,
|
||||
path: '/',
|
||||
method: 'POST',
|
||||
},
|
||||
common.mustCall((res) => {
|
||||
res.on('end', function() {
|
||||
server.close();
|
||||
});
|
||||
res.resume();
|
||||
})
|
||||
);
|
||||
|
||||
req.write('BODY');
|
||||
req.end();
|
||||
})
|
||||
);
|
@ -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' });
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user