mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
stream: Writable should ignore encoding for buffers
Fix #4727 Fix einaros/ws#159
This commit is contained in:
@@ -150,8 +150,8 @@ Writable.prototype.write = function(chunk, encoding, cb) {
|
||||
len = chunk.length;
|
||||
if (false === state.decodeStrings)
|
||||
chunk = [chunk, encoding || 'utf8'];
|
||||
else if (typeof chunk === 'string' || encoding) {
|
||||
chunk = new Buffer(chunk + '', encoding);
|
||||
else if (typeof chunk === 'string') {
|
||||
chunk = new Buffer(chunk, encoding);
|
||||
len = chunk.length;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,3 +280,14 @@ test('end callback after .write() call', function (t) {
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
test('encoding should be ignored for buffers', function(t) {
|
||||
var tw = new W();
|
||||
var hex = '018b5e9a8f6236ffe30e31baf80d2cf6eb';
|
||||
tw._write = function(chunk, cb) {
|
||||
t.equal(chunk.toString('hex'), hex);
|
||||
t.end();
|
||||
};
|
||||
var buf = new Buffer(hex, 'hex');
|
||||
tw.write(buf, 'binary');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user