node/test/parallel/test-http-outgoing-internal-headers.js
Morgan Roderick 91748dd89c http: change DEP0066 to a runtime deprecation
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>
2018-11-22 04:45:27 -08:00

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']
}));
}