Skip to content

Commit 91748dd

Browse files
mroderickTrott
authored andcommitted
http: change DEP0066 to a runtime deprecation
Change doc-only deprecation for _headers and _headerNames accessors to a runtime deprecation. PR-URL: #24167 Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]>
1 parent 070995d commit 91748dd

5 files changed

+43
-9
lines changed

doc/api/deprecations.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1344,12 +1344,15 @@ removed. Please use `sloppy` instead.
13441344
### DEP0066: outgoingMessage.\_headers, outgoingMessage.\_headerNames
13451345
<!-- YAML
13461346
changes:
1347+
- version: REPLACEME
1348+
pr-url: https://github.com/nodejs/node/pull/24167
1349+
description: Runtime deprecation.
13471350
- version: v8.0.0
13481351
pr-url: https://github.com/nodejs/node/pull/10941
13491352
description: Documentation-only deprecation.
13501353
-->
13511354

1352-
Type: Documentation-only
1355+
Type: Runtime
13531356

13541357
The `http` module `outgoingMessage._headers` and `outgoingMessage._headerNames`
13551358
properties are deprecated. Use one of the public methods

lib/_http_outgoing.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ util.inherits(OutgoingMessage, Stream);
110110

111111

112112
Object.defineProperty(OutgoingMessage.prototype, '_headers', {
113-
get: function() {
113+
get: util.deprecate(function() {
114114
return this.getHeaders();
115-
},
116-
set: function(val) {
115+
}, 'OutgoingMessage.prototype._headers is deprecated', 'DEP0066'),
116+
set: util.deprecate(function(val) {
117117
if (val == null) {
118118
this[outHeadersKey] = null;
119119
} else if (typeof val === 'object') {
@@ -124,11 +124,11 @@ Object.defineProperty(OutgoingMessage.prototype, '_headers', {
124124
headers[name.toLowerCase()] = [name, val[name]];
125125
}
126126
}
127-
}
127+
}, 'OutgoingMessage.prototype._headers is deprecated', 'DEP0066')
128128
});
129129

130130
Object.defineProperty(OutgoingMessage.prototype, '_headerNames', {
131-
get: function() {
131+
get: util.deprecate(function() {
132132
const headers = this[outHeadersKey];
133133
if (headers !== null) {
134134
const out = Object.create(null);
@@ -141,8 +141,8 @@ Object.defineProperty(OutgoingMessage.prototype, '_headerNames', {
141141
return out;
142142
}
143143
return null;
144-
},
145-
set: function(val) {
144+
}, 'OutgoingMessage.prototype._headerNames is deprecated', 'DEP0066'),
145+
set: util.deprecate(function(val) {
146146
if (typeof val === 'object' && val !== null) {
147147
const headers = this[outHeadersKey];
148148
if (!headers)
@@ -154,7 +154,7 @@ Object.defineProperty(OutgoingMessage.prototype, '_headerNames', {
154154
header[0] = val[keys[i]];
155155
}
156156
}
157-
}
157+
}, 'OutgoingMessage.prototype._headerNames is deprecated', 'DEP0066')
158158
});
159159

160160

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
const { OutgoingMessage } = require('http');
5+
6+
const warn = 'OutgoingMessage.prototype._headerNames is deprecated';
7+
common.expectWarning('DeprecationWarning', warn, 'DEP0066');
8+
9+
{
10+
// tests for _headerNames get method
11+
const outgoingMessage = new OutgoingMessage();
12+
outgoingMessage._headerNames;
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
const common = require('../common');
3+
4+
const { OutgoingMessage } = require('http');
5+
6+
const warn = 'OutgoingMessage.prototype._headerNames is deprecated';
7+
common.expectWarning('DeprecationWarning', warn, 'DEP0066');
8+
9+
{
10+
// tests for _headerNames set method
11+
const outgoingMessage = new OutgoingMessage();
12+
outgoingMessage._headerNames = {
13+
'x-flow-id': '61bba6c5-28a3-4eab-9241-2ecaa6b6a1fd'
14+
};
15+
}

test/parallel/test-http-outgoing-internal-headers.js

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ const assert = require('assert');
66
const { outHeadersKey } = require('internal/http');
77
const { OutgoingMessage } = require('http');
88

9+
const warn = 'OutgoingMessage.prototype._headers is deprecated';
10+
common.expectWarning('DeprecationWarning', warn, 'DEP0066');
11+
912
{
1013
// tests for _headers get method
1114
const outgoingMessage = new OutgoingMessage();

0 commit comments

Comments
 (0)