mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 20:25:27 +00:00

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: https://github.com/nodejs/node/pull/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>
16 lines
504 B
JavaScript
16 lines
504 B
JavaScript
'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'
|
|
);
|