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 156549d

Browse filesBrowse files
Kashermcollina
authored andcommitted
http: disable OutgoingMessage pipe method
OutgoingMessage should be a write-only stream, and it shouldn't be piped. This commit disables the `pipe` method by throwing an exception (if this method is called). PR-URL: #14358 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
1 parent c49adbf commit 156549d
Copy full SHA for 156549d

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

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

‎lib/_http_outgoing.js‎

Copy file name to clipboardExpand all lines: lib/_http_outgoing.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,10 @@ OutgoingMessage.prototype.flush = internalUtil.deprecate(function() {
889889
this.flushHeaders();
890890
}, 'OutgoingMessage.flush is deprecated. Use flushHeaders instead.', 'DEP0001');
891891

892+
OutgoingMessage.prototype.pipe = function pipe() {
893+
// OutgoingMessage should be write-only. Piping from it is disabled.
894+
this.emit('error', new Error('Cannot pipe, not readable'));
895+
};
892896

893897
module.exports = {
894898
OutgoingMessage
Collapse file
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
const assert = require('assert');
3+
const common = require('../common');
4+
const OutgoingMessage = require('_http_outgoing').OutgoingMessage;
5+
6+
// Verify that an error is thrown upon a call to `OutgoingMessage.pipe`.
7+
8+
const outgoingMessage = new OutgoingMessage();
9+
assert.throws(
10+
common.mustCall(() => { outgoingMessage.pipe(outgoingMessage); }),
11+
(err) => {
12+
return ((err instanceof Error) && /Cannot pipe, not readable/.test(err));
13+
},
14+
'OutgoingMessage.pipe should throw an error'
15+
);

0 commit comments

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