mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
http: deprecate writeHeader
PR-URL: https://github.com/nodejs/node/pull/59060 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Tim Perry <pimterry@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
This commit is contained in:
parent
eabb75cea8
commit
91dadf2897
3 changed files with 28 additions and 3 deletions
|
@ -1480,12 +1480,15 @@ instead.
|
||||||
|
|
||||||
<!-- YAML
|
<!-- YAML
|
||||||
changes:
|
changes:
|
||||||
|
- version: REPLACEME
|
||||||
|
pr-url: https://github.com/nodejs/node/pull/59060
|
||||||
|
description: Runtime deprecation.
|
||||||
- version: v8.0.0
|
- version: v8.0.0
|
||||||
pr-url: https://github.com/nodejs/node/pull/11355
|
pr-url: https://github.com/nodejs/node/pull/11355
|
||||||
description: Documentation-only deprecation.
|
description: Documentation-only deprecation.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
Type: Documentation-only
|
Type: Runtime
|
||||||
|
|
||||||
The `node:http` module `ServerResponse.prototype.writeHeader()` API is
|
The `node:http` module `ServerResponse.prototype.writeHeader()` API is
|
||||||
deprecated. Please use `ServerResponse.prototype.writeHead()` instead.
|
deprecated. Please use `ServerResponse.prototype.writeHead()` instead.
|
||||||
|
|
|
@ -81,6 +81,7 @@ const {
|
||||||
} = require('internal/errors');
|
} = require('internal/errors');
|
||||||
const {
|
const {
|
||||||
assignFunctionName,
|
assignFunctionName,
|
||||||
|
deprecate,
|
||||||
kEmptyObject,
|
kEmptyObject,
|
||||||
promisify,
|
promisify,
|
||||||
} = require('internal/util');
|
} = require('internal/util');
|
||||||
|
@ -439,8 +440,9 @@ function writeHead(statusCode, reason, obj) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Docs-only deprecated: DEP0063
|
ServerResponse.prototype.writeHeader = deprecate(ServerResponse.prototype.writeHead,
|
||||||
ServerResponse.prototype.writeHeader = ServerResponse.prototype.writeHead;
|
'ServerResponse.prototype.writeHeader is deprecated.',
|
||||||
|
'DEP0063');
|
||||||
|
|
||||||
function storeHTTPOptions(options) {
|
function storeHTTPOptions(options) {
|
||||||
this[kIncomingMessage] = options.IncomingMessage || IncomingMessage;
|
this[kIncomingMessage] = options.IncomingMessage || IncomingMessage;
|
||||||
|
|
20
test/parallel/test-write-header.js
Normal file
20
test/parallel/test-write-header.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
'use strict';
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const http = require('http');
|
||||||
|
|
||||||
|
common.expectWarning('DeprecationWarning',
|
||||||
|
'ServerResponse.prototype.writeHeader is deprecated.', 'DEP0063');
|
||||||
|
|
||||||
|
const server = http.createServer(common.mustCall((req, res) => {
|
||||||
|
res.writeHeader(200, [ 'test', '2', 'test2', '2' ]);
|
||||||
|
res.end();
|
||||||
|
})).listen(0, common.mustCall(() => {
|
||||||
|
http.get({ port: server.address().port }, common.mustCall((res) => {
|
||||||
|
assert.strictEqual(res.headers.test, '2');
|
||||||
|
assert.strictEqual(res.headers.test2, '2');
|
||||||
|
res.resume().on('end', common.mustCall(() => {
|
||||||
|
server.close();
|
||||||
|
}));
|
||||||
|
}));
|
||||||
|
}));
|
Loading…
Add table
Add a link
Reference in a new issue