| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent eabb75c commit 91dadf2
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1480,12 +1480,15 @@ instead. | |||
| 1480 | 1480 | ||
| 1481 | 1481 | <!-- YAML | |
| 1482 | 1482 | changes: | |
| 1483 | + - version: REPLACEME | ||
| 1484 | + pr-url: https://github.com/nodejs/node/pull/59060 | ||
| 1485 | + description: Runtime deprecation. | ||
| 1483 | 1486 | - version: v8.0.0 | |
| 1484 | 1487 | pr-url: https://github.com/nodejs/node/pull/11355 | |
| 1485 | 1488 | description: Documentation-only deprecation. | |
| 1486 | 1489 | --> | |
| 1487 | 1490 | ||
| 1488 | - Type: Documentation-only | ||
| 1491 | + Type: Runtime | ||
| 1489 | 1492 | ||
| 1490 | 1493 | The `node:http` module `ServerResponse.prototype.writeHeader()` API is | |
| 1491 | 1494 | deprecated. Please use `ServerResponse.prototype.writeHead()` instead. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -81,6 +81,7 @@ const { | |||
| 81 | 81 | } = require('internal/errors'); | |
| 82 | 82 | const { | |
| 83 | 83 | assignFunctionName, | |
| 84 | + deprecate, | ||
| 84 | 85 | kEmptyObject, | |
| 85 | 86 | promisify, | |
| 86 | 87 | } = require('internal/util'); | |
@@ -439,8 +440,9 @@ function writeHead(statusCode, reason, obj) { | |||
| 439 | 440 | return this; | |
| 440 | 441 | } | |
| 441 | 442 | ||
| 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'); | ||
| 444 | 446 | ||
| 445 | 447 | function storeHTTPOptions(options) { | |
| 446 | 448 | this[kIncomingMessage] = options.IncomingMessage || IncomingMessage; | |
| Original file line number | Diff line number | Diff 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 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments