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>
This commit is contained in:
parent
070995d586
commit
91748dd89c
@ -1344,12 +1344,15 @@ removed. Please use `sloppy` instead.
|
|||||||
### DEP0066: outgoingMessage.\_headers, outgoingMessage.\_headerNames
|
### DEP0066: outgoingMessage.\_headers, outgoingMessage.\_headerNames
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
changes:
|
changes:
|
||||||
|
- version: REPLACEME
|
||||||
|
pr-url: https://github.com/nodejs/node/pull/24167
|
||||||
|
description: Runtime deprecation.
|
||||||
- version: v8.0.0
|
- version: v8.0.0
|
||||||
pr-url: https://github.com/nodejs/node/pull/10941
|
pr-url: https://github.com/nodejs/node/pull/10941
|
||||||
description: Documentation-only deprecation.
|
description: Documentation-only deprecation.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
Type: Documentation-only
|
Type: Runtime
|
||||||
|
|
||||||
The `http` module `outgoingMessage._headers` and `outgoingMessage._headerNames`
|
The `http` module `outgoingMessage._headers` and `outgoingMessage._headerNames`
|
||||||
properties are deprecated. Use one of the public methods
|
properties are deprecated. Use one of the public methods
|
||||||
|
@ -110,10 +110,10 @@ util.inherits(OutgoingMessage, Stream);
|
|||||||
|
|
||||||
|
|
||||||
Object.defineProperty(OutgoingMessage.prototype, '_headers', {
|
Object.defineProperty(OutgoingMessage.prototype, '_headers', {
|
||||||
get: function() {
|
get: util.deprecate(function() {
|
||||||
return this.getHeaders();
|
return this.getHeaders();
|
||||||
},
|
}, 'OutgoingMessage.prototype._headers is deprecated', 'DEP0066'),
|
||||||
set: function(val) {
|
set: util.deprecate(function(val) {
|
||||||
if (val == null) {
|
if (val == null) {
|
||||||
this[outHeadersKey] = null;
|
this[outHeadersKey] = null;
|
||||||
} else if (typeof val === 'object') {
|
} else if (typeof val === 'object') {
|
||||||
@ -124,11 +124,11 @@ Object.defineProperty(OutgoingMessage.prototype, '_headers', {
|
|||||||
headers[name.toLowerCase()] = [name, val[name]];
|
headers[name.toLowerCase()] = [name, val[name]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}, 'OutgoingMessage.prototype._headers is deprecated', 'DEP0066')
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.defineProperty(OutgoingMessage.prototype, '_headerNames', {
|
Object.defineProperty(OutgoingMessage.prototype, '_headerNames', {
|
||||||
get: function() {
|
get: util.deprecate(function() {
|
||||||
const headers = this[outHeadersKey];
|
const headers = this[outHeadersKey];
|
||||||
if (headers !== null) {
|
if (headers !== null) {
|
||||||
const out = Object.create(null);
|
const out = Object.create(null);
|
||||||
@ -141,8 +141,8 @@ Object.defineProperty(OutgoingMessage.prototype, '_headerNames', {
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
}, 'OutgoingMessage.prototype._headerNames is deprecated', 'DEP0066'),
|
||||||
set: function(val) {
|
set: util.deprecate(function(val) {
|
||||||
if (typeof val === 'object' && val !== null) {
|
if (typeof val === 'object' && val !== null) {
|
||||||
const headers = this[outHeadersKey];
|
const headers = this[outHeadersKey];
|
||||||
if (!headers)
|
if (!headers)
|
||||||
@ -154,7 +154,7 @@ Object.defineProperty(OutgoingMessage.prototype, '_headerNames', {
|
|||||||
header[0] = val[keys[i]];
|
header[0] = val[keys[i]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}, 'OutgoingMessage.prototype._headerNames is deprecated', 'DEP0066')
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
'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 get method
|
||||||
|
const outgoingMessage = new OutgoingMessage();
|
||||||
|
outgoingMessage._headerNames;
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
'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'
|
||||||
|
};
|
||||||
|
}
|
@ -6,6 +6,9 @@ const assert = require('assert');
|
|||||||
const { outHeadersKey } = require('internal/http');
|
const { outHeadersKey } = require('internal/http');
|
||||||
const { OutgoingMessage } = require('http');
|
const { OutgoingMessage } = require('http');
|
||||||
|
|
||||||
|
const warn = 'OutgoingMessage.prototype._headers is deprecated';
|
||||||
|
common.expectWarning('DeprecationWarning', warn, 'DEP0066');
|
||||||
|
|
||||||
{
|
{
|
||||||
// tests for _headers get method
|
// tests for _headers get method
|
||||||
const outgoingMessage = new OutgoingMessage();
|
const outgoingMessage = new OutgoingMessage();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user