diff --git a/lib/net.js b/lib/net.js index b5951acb322..81073be7ca3 100644 --- a/lib/net.js +++ b/lib/net.js @@ -329,6 +329,9 @@ function initStream (self) { case 'ascii': string = recvBuffer.asciiSlice(start, end); break; + case 'binary': + string = recvBuffer.binarySlice(start, end); + break; default: throw new Error('Unsupported encoding ' + self._encoding + '. Use Buffer'); } @@ -513,9 +516,12 @@ Stream.prototype.write = function (data, encoding) { var charsWritten; if (encoding == 'utf8') { recvBuffer.utf8Write(data, recvBuffer.used); - } else { + } else if (encoding == 'ascii') { // ascii recvBuffer.asciiWrite(data, recvBuffer.used); + } else { + // binary + recvBuffer.binaryWrite(data, recvBuffer.used); } buffer = recvBuffer;