summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2013-08-27 14:53:06 -0700
committerisaacs <i@izs.me>2013-08-27 14:53:06 -0700
commita3da3e73121d68615c5408814284d333f38db692 (patch)
tree5fcbb652e2d2fa625c27c39f237b4b34360a4a0d /lib
parent5508236c49ee71792041fb6e62cfd2af3de60e6c (diff)
downloadandroid-node-v8-a3da3e73121d68615c5408814284d333f38db692.tar.gz
android-node-v8-a3da3e73121d68615c5408814284d333f38db692.tar.bz2
android-node-v8-a3da3e73121d68615c5408814284d333f38db692.zip
stream: Pass 'buffer' encoding to decoded writables
Since the encoding is no longer relevant once it is decoded to a Buffer, it is confusing and incorrect to pass the encoding as 'utf8' or whatever in those cases. Closes #6119
Diffstat (limited to 'lib')
-rw-r--r--lib/_stream_writable.js2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js
index a26f711c1d..601f5b713f 100644
--- a/lib/_stream_writable.js
+++ b/lib/_stream_writable.js
@@ -196,6 +196,8 @@ function decodeChunk(state, chunk, encoding) {
// If we return false, then we need a drain event, so set that flag.
function writeOrBuffer(stream, state, chunk, encoding, cb) {
chunk = decodeChunk(state, chunk, encoding);
+ if (Buffer.isBuffer(chunk))
+ encoding = 'buffer';
var len = state.objectMode ? 1 : chunk.length;
state.length += len;