Skip to content

Commit a986aa3

Browse files
authored
Merge branch 'nodejs:main' into main
2 parents 35b1825 + 91dadf2 commit a986aa3

File tree

5 files changed

+31
-10
lines changed

5 files changed

+31
-10
lines changed

doc/api/deprecations.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1480,12 +1480,15 @@ instead.
14801480

14811481
<!-- YAML
14821482
changes:
1483+
- version: REPLACEME
1484+
pr-url: https://github.com/nodejs/node/pull/59060
1485+
description: Runtime deprecation.
14831486
- version: v8.0.0
14841487
pr-url: https://github.com/nodejs/node/pull/11355
14851488
description: Documentation-only deprecation.
14861489
-->
14871490

1488-
Type: Documentation-only
1491+
Type: Runtime
14891492

14901493
The `node:http` module `ServerResponse.prototype.writeHeader()` API is
14911494
deprecated. Please use `ServerResponse.prototype.writeHead()` instead.

lib/_http_server.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ const {
8181
} = require('internal/errors');
8282
const {
8383
assignFunctionName,
84+
deprecate,
8485
kEmptyObject,
8586
promisify,
8687
} = require('internal/util');
@@ -439,8 +440,9 @@ function writeHead(statusCode, reason, obj) {
439440
return this;
440441
}
441442

442-
// Docs-only deprecated: DEP0063
443-
ServerResponse.prototype.writeHeader = ServerResponse.prototype.writeHead;
443+
ServerResponse.prototype.writeHeader = deprecate(ServerResponse.prototype.writeHead,
444+
'ServerResponse.prototype.writeHeader is deprecated.',
445+
'DEP0063');
444446

445447
function storeHTTPOptions(options) {
446448
this[kIncomingMessage] = options.IncomingMessage || IncomingMessage;

lib/events.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const {
2828
ArrayPrototypeSlice,
2929
ArrayPrototypeSplice,
3030
ArrayPrototypeUnshift,
31+
AsyncIteratorPrototype,
3132
Boolean,
3233
Error,
3334
ErrorCaptureStackTrace,
@@ -1000,9 +1001,6 @@ async function once(emitter, name, options = kEmptyObject) {
10001001
});
10011002
}
10021003

1003-
const AsyncIteratorPrototype = ObjectGetPrototypeOf(
1004-
ObjectGetPrototypeOf(async function* () {}).prototype);
1005-
10061004
function createIterResult(value, done) {
10071005
return { value, done };
10081006
}

lib/internal/freeze_intrinsics.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const {
3131
ArrayPrototype,
3232
ArrayPrototypeForEach,
3333
ArrayPrototypePush,
34+
AsyncIteratorPrototype,
3435
Atomics,
3536
BigInt,
3637
BigInt64Array,
@@ -212,10 +213,7 @@ module.exports = function() {
212213
// 27 Control Abstraction Objects
213214
// 27.1 Iteration
214215
IteratorPrototype, // 27.1.2 IteratorPrototype
215-
// 27.1.3 AsyncIteratorPrototype
216-
ObjectGetPrototypeOf(ObjectGetPrototypeOf(ObjectGetPrototypeOf(
217-
(async function*() {})(),
218-
))),
216+
AsyncIteratorPrototype, // 27.1.3 AsyncIteratorPrototype
219217
PromisePrototype, // 27.2
220218

221219
// Other APIs / Web Compatibility

test/parallel/test-write-header.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const http = require('http');
5+
6+
common.expectWarning('DeprecationWarning',
7+
'ServerResponse.prototype.writeHeader is deprecated.', 'DEP0063');
8+
9+
const server = http.createServer(common.mustCall((req, res) => {
10+
res.writeHeader(200, [ 'test', '2', 'test2', '2' ]);
11+
res.end();
12+
})).listen(0, common.mustCall(() => {
13+
http.get({ port: server.address().port }, common.mustCall((res) => {
14+
assert.strictEqual(res.headers.test, '2');
15+
assert.strictEqual(res.headers.test2, '2');
16+
res.resume().on('end', common.mustCall(() => {
17+
server.close();
18+
}));
19+
}));
20+
}));

0 commit comments

Comments
 (0)