Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fb68487

Browse filesBrowse files
cjihrigaddaleax
authored andcommitted
http: return this from IncomingMessage#destroy()
This commit updates IncomingMessage#destroy() to return `this` for consistency with other readable streams. PR-URL: #32789 Fixes: #32772 Reviewed-By: Robert Nagy <ronagy@icloud.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 1b24d3a commit fb68487
Copy full SHA for fb68487

File tree

Expand file treeCollapse file tree

3 files changed

+17
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+17
-0
lines changed
Open diff view settings
Collapse file

‎doc/api/http.md‎

Copy file name to clipboardExpand all lines: doc/api/http.md
+6Lines changed: 6 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1833,9 +1833,15 @@ const req = http.request({
18331833
### `message.destroy([error])`
18341834
<!-- YAML
18351835
added: v0.3.0
1836+
changes:
1837+
- version: REPLACEME
1838+
pr-url: https://github.com/nodejs/node/pull/32789
1839+
description: The function returns `this` for consistency with other Readable
1840+
streams.
18361841
-->
18371842

18381843
* `error` {Error}
1844+
* Returns: {this}
18391845

18401846
Calls `destroy()` on the socket that received the `IncomingMessage`. If `error`
18411847
is provided, an `'error'` event is emitted on the socket and `error` is passed
Collapse file

‎lib/_http_incoming.js‎

Copy file name to clipboardExpand all lines: lib/_http_incoming.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ IncomingMessage.prototype._read = function _read(n) {
114114
IncomingMessage.prototype.destroy = function destroy(error) {
115115
if (this.socket)
116116
this.socket.destroy(error);
117+
return this;
117118
};
118119

119120

Collapse file
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
3+
// Test that http.IncomingMessage,prototype.destroy() returns `this`.
4+
require('../common');
5+
6+
const assert = require('assert');
7+
const http = require('http');
8+
const incomingMessage = new http.IncomingMessage();
9+
10+
assert.strictEqual(incomingMessage.destroy(), incomingMessage);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.