Skip to content

Commit

Permalink
Implement PassThrough stream to insulate output
Browse files Browse the repository at this point in the history
  • Loading branch information
mikermcneil committed Aug 24, 2018
1 parent 09b0bd1 commit 981e0d9
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/machine-as-action.js
Original file line number Diff line number Diff line change
Expand Up @@ -931,8 +931,17 @@ module.exports = function machineAsAction(optsOrMachineDef) {
} catch (err) { console.error('Consistency violation: Unexpected internal error:',err); }
});//æ

// Construct a pass-through stream to adjust for any weirdness
// in the output stream (e.g. otherwise if it came from the
// `request` package aka sails.helpers.http.*, then it could
// leak headers or other potentially sensitive information, or
// cause compatibility issues.)
// > Note: This PassThrough approach isn't free as far as performance,
// > but we feel it's an acceptable price. For more on that, see:
// > https://www.vperi.com/archives/520
var passThrough = new Stream.PassThrough();
res.status(responses[exitCodeName].statusCode);
return output.pipe(res);
return output.pipe(passThrough).pipe(res);

This comment has been minimized.

Copy link
@mikermcneil

mikermcneil Jan 19, 2019

Author Member

this is for sending a file download as the response

}
// • Buffer
else if (output instanceof Buffer) {
Expand Down

1 comment on commit 981e0d9

@mikermcneil
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.