Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add deprecation warning DEP0066 #24167

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -1344,12 +1344,15 @@ removed. Please use `sloppy` instead.
### DEP0066: outgoingMessage.\_headers, outgoingMessage.\_headerNames
<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/24167
description: Runtime deprecation.
- version: v8.0.0
pr-url: https://github.com/nodejs/node/pull/10941
description: Documentation-only deprecation.
-->

Type: Documentation-only
Type: Runtime

The `http` module `outgoingMessage._headers` and `outgoingMessage._headerNames`
properties are deprecated. Use one of the public methods
Expand Down
16 changes: 8 additions & 8 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ util.inherits(OutgoingMessage, Stream);


Object.defineProperty(OutgoingMessage.prototype, '_headers', {
get: function() {
get: util.deprecate(function() {
return this.getHeaders();
},
set: function(val) {
}, 'OutgoingMessage.prototype._headers is deprecated', 'DEP0066'),
set: util.deprecate(function(val) {
if (val == null) {
this[outHeadersKey] = null;
} else if (typeof val === 'object') {
Expand All @@ -124,11 +124,11 @@ Object.defineProperty(OutgoingMessage.prototype, '_headers', {
headers[name.toLowerCase()] = [name, val[name]];
}
}
}
}, 'OutgoingMessage.prototype._headers is deprecated', 'DEP0066')
});

Object.defineProperty(OutgoingMessage.prototype, '_headerNames', {
get: function() {
get: util.deprecate(function() {
const headers = this[outHeadersKey];
if (headers !== null) {
const out = Object.create(null);
Expand All @@ -141,8 +141,8 @@ Object.defineProperty(OutgoingMessage.prototype, '_headerNames', {
return out;
}
return null;
},
set: function(val) {
}, 'OutgoingMessage.prototype._headerNames is deprecated', 'DEP0066'),
set: util.deprecate(function(val) {
if (typeof val === 'object' && val !== null) {
const headers = this[outHeadersKey];
if (!headers)
Expand All @@ -154,7 +154,7 @@ Object.defineProperty(OutgoingMessage.prototype, '_headerNames', {
header[0] = val[keys[i]];
}
}
}
}, 'OutgoingMessage.prototype._headerNames is deprecated', 'DEP0066')
});


Expand Down
13 changes: 13 additions & 0 deletions test/parallel/test-http-outgoing-internal-headernames-getter.js
Original file line number Diff line number Diff line change
@@ -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;
}
15 changes: 15 additions & 0 deletions test/parallel/test-http-outgoing-internal-headernames-setter.js
Original file line number Diff line number Diff line change
@@ -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'
};
}
3 changes: 3 additions & 0 deletions test/parallel/test-http-outgoing-internal-headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ 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();
Expand Down