0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

Support old 'binary' encoding in net.js

This commit is contained in:
Ryan Dahl 2010-03-19 21:25:29 -07:00
parent 663269f687
commit 139c91e892

View File

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