diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 392ef09c2ca3e2..aa748096a3ae7e 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -1545,6 +1545,9 @@ removed. Please use `sloppy` instead. -Type: Runtime +Type: End-of-Life The `node:http` module `OutgoingMessage.prototype._headers` and `OutgoingMessage.prototype._headerNames` properties are deprecated. Use one of diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index c7dbc3a6ac82eb..dd29631ccddabb 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -38,7 +38,6 @@ const { getDefaultHighWaterMark } = require('internal/streams/state'); const assert = require('internal/assert'); const EE = require('events'); const Stream = require('stream'); -const internalUtil = require('internal/util'); const { kOutHeaders, utcDate, kNeedDrain } = require('internal/http'); const { Buffer } = require('buffer'); const { @@ -211,27 +210,6 @@ ObjectDefineProperty(OutgoingMessage.prototype, 'writableCorked', { }, }); -ObjectDefineProperty(OutgoingMessage.prototype, '_headers', { - __proto__: null, - get: internalUtil.deprecate(function() { - return this.getHeaders(); - }, 'OutgoingMessage.prototype._headers is deprecated', 'DEP0066'), - set: internalUtil.deprecate(function(val) { - if (val == null) { - this[kOutHeaders] = null; - } else if (typeof val === 'object') { - const headers = this[kOutHeaders] = { __proto__: null }; - const keys = ObjectKeys(val); - // Retain for(;;) loop for performance reasons - // Refs: https://github.com/nodejs/node/pull/30958 - for (let i = 0; i < keys.length; ++i) { - const name = keys[i]; - headers[name.toLowerCase()] = [name, val[name]]; - } - } - }, 'OutgoingMessage.prototype._headers is deprecated', 'DEP0066'), -}); - ObjectDefineProperty(OutgoingMessage.prototype, 'connection', { __proto__: null, get: function() { @@ -256,42 +234,6 @@ ObjectDefineProperty(OutgoingMessage.prototype, 'socket', { }, }); -ObjectDefineProperty(OutgoingMessage.prototype, '_headerNames', { - __proto__: null, - get: internalUtil.deprecate(function() { - const headers = this[kOutHeaders]; - if (headers !== null) { - const out = { __proto__: null }; - const keys = ObjectKeys(headers); - // Retain for(;;) loop for performance reasons - // Refs: https://github.com/nodejs/node/pull/30958 - for (let i = 0; i < keys.length; ++i) { - const key = keys[i]; - const val = headers[key][0]; - out[key] = val; - } - return out; - } - return null; - }, 'OutgoingMessage.prototype._headerNames is deprecated', 'DEP0066'), - set: internalUtil.deprecate(function(val) { - if (typeof val === 'object' && val !== null) { - const headers = this[kOutHeaders]; - if (!headers) - return; - const keys = ObjectKeys(val); - // Retain for(;;) loop for performance reasons - // Refs: https://github.com/nodejs/node/pull/30958 - for (let i = 0; i < keys.length; ++i) { - const header = headers[keys[i]]; - if (header) - header[0] = val[keys[i]]; - } - } - }, 'OutgoingMessage.prototype._headerNames is deprecated', 'DEP0066'), -}); - - OutgoingMessage.prototype._renderHeaders = function _renderHeaders() { if (this._header) { throw new ERR_HTTP_HEADERS_SENT('render'); diff --git a/test/parallel/test-http-outgoing-internal-headernames-getter.js b/test/parallel/test-http-outgoing-internal-headernames-getter.js deleted file mode 100644 index 15c3f299eb25c2..00000000000000 --- a/test/parallel/test-http-outgoing-internal-headernames-getter.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; -const common = require('../common'); - -const { OutgoingMessage } = require('http'); -const assert = require('assert'); - -const warn = 'OutgoingMessage.prototype._headerNames is deprecated'; -common.expectWarning('DeprecationWarning', warn, 'DEP0066'); - -{ - // Tests for _headerNames get method - const outgoingMessage = new OutgoingMessage(); - outgoingMessage._headerNames; // eslint-disable-line no-unused-expressions -} - -{ - // Tests _headerNames getter result after setting a header. - const outgoingMessage = new OutgoingMessage(); - outgoingMessage.setHeader('key', 'value'); - const expect = { __proto__: null }; - expect.key = 'key'; - assert.deepStrictEqual(outgoingMessage._headerNames, expect); -} diff --git a/test/parallel/test-http-outgoing-internal-headernames-setter.js b/test/parallel/test-http-outgoing-internal-headernames-setter.js deleted file mode 100644 index 5f943596dfb015..00000000000000 --- a/test/parallel/test-http-outgoing-internal-headernames-setter.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; -const common = require('../common'); - -const { OutgoingMessage } = require('http'); - -const warn = 'OutgoingMessage.prototype._headerNames is deprecated'; -common.expectWarning('DeprecationWarning', warn, 'DEP0066'); - -{ - // Tests for _headerNames set method - const outgoingMessage = new OutgoingMessage(); - outgoingMessage._headerNames = { - 'x-flow-id': '61bba6c5-28a3-4eab-9241-2ecaa6b6a1fd' - }; -} diff --git a/test/parallel/test-http-outgoing-internal-headers.js b/test/parallel/test-http-outgoing-internal-headers.js deleted file mode 100644 index 17de5e7d075ce5..00000000000000 --- a/test/parallel/test-http-outgoing-internal-headers.js +++ /dev/null @@ -1,44 +0,0 @@ -// Flags: --expose-internals -'use strict'; -const common = require('../common'); -const assert = require('assert'); - -const { kOutHeaders } = 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; // eslint-disable-line no-unused-expressions -} - -{ - // Tests for _headers set method - const outgoingMessage = new OutgoingMessage(); - outgoingMessage._headers = { - host: 'risingstack.com', - Origin: 'localhost' - }; - - assert.deepStrictEqual( - Object.entries(outgoingMessage[kOutHeaders]), - Object.entries({ - host: ['host', 'risingstack.com'], - origin: ['Origin', 'localhost'] - })); -} - -{ - // Tests for _headers set method `null` - const outgoingMessage = new OutgoingMessage(); - outgoingMessage._headers = null; - - assert.strictEqual( - outgoingMessage[kOutHeaders], - null - ); -}