-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]>
- Loading branch information
Showing
2 changed files
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
const assert = require('assert'); | ||
const common = require('../common'); | ||
const OutgoingMessage = require('_http_outgoing').OutgoingMessage; | ||
|
||
// Verify that an error is thrown upon a call to `OutgoingMessage.pipe`. | ||
|
||
const outgoingMessage = new OutgoingMessage(); | ||
assert.throws( | ||
common.mustCall(() => { outgoingMessage.pipe(outgoingMessage); }), | ||
(err) => { | ||
return ((err instanceof Error) && /Cannot pipe, not readable/.test(err)); | ||
}, | ||
'OutgoingMessage.pipe should throw an error' | ||
); |