mirror of
https://github.com/nodejs/node.git
synced 2025-05-05 15:32:15 +00:00

Change doc-only deprecation for _headers and _headerNames accessors to a runtime deprecation. PR-URL: https://github.com/nodejs/node/pull/24167 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
34 lines
872 B
JavaScript
34 lines
872 B
JavaScript
// Flags: --expose-internals
|
|
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
const { outHeadersKey } = require('internal/http');
|
|
const { OutgoingMessage } = require('http');
|
|
|
|
const warn = 'OutgoingMessage.prototype._headers is deprecated';
|
|
common.expectWarning('DeprecationWarning', warn, 'DEP0066');
|
|
|
|
{
|
|
// tests for _headers get method
|
|
const outgoingMessage = new OutgoingMessage();
|
|
outgoingMessage.getHeaders = common.mustCall();
|
|
outgoingMessage._headers;
|
|
}
|
|
|
|
{
|
|
// tests for _headers set method
|
|
const outgoingMessage = new OutgoingMessage();
|
|
outgoingMessage._headers = {
|
|
host: 'risingstack.com',
|
|
Origin: 'localhost'
|
|
};
|
|
|
|
assert.deepStrictEqual(
|
|
Object.entries(outgoingMessage[outHeadersKey]),
|
|
Object.entries({
|
|
host: ['host', 'risingstack.com'],
|
|
origin: ['Origin', 'localhost']
|
|
}));
|
|
}
|