Skip to content
Browse files

Use binary encoding for arg serialization when not a Buffer.

  • Loading branch information...
1 parent c0ef7d6 commit bd86792ebbafe2ae063d169a5e61e60a80f4057e @fictorial fictorial committed May 7, 2010
Showing with 5 additions and 11 deletions.
  1. +3 −3 lib/redis-client.js
  2. +2 −8 test/test.js
View
6 lib/redis-client.js
@@ -714,9 +714,9 @@ Client.prototype.sendCommand = function () {
offset += this.requestBuffer.asciiWrite(CRLF, offset);
} else if (arg.toString) {
var asString = arg.toString();
- var serialized = '$' + Buffer.byteLength(asString) + CRLF + asString + CRLF;
- ensureSpaceFor(Buffer.byteLength(serialized));
- offset += this.requestBuffer.utf8Write(serialized, offset);
+ var serialized = '$' + Buffer.byteLength(asString, "binary") + CRLF + asString + CRLF;
+ ensureSpaceFor(Buffer.byteLength(serialized, "binary"));
+ offset += this.requestBuffer.binaryWrite(serialized, offset);
}
}
View
10 test/test.js
@@ -1743,13 +1743,7 @@ var allTestFunctions = [
function testLargeGetSet() {
showTestBanner("testLargeGetSet");
- var fileContents = fs.readFileSync(__filename);
-
-// if (Buffer.byteLength(fileContents) < client.requestBuffer.length) {
-// sys.debug(Buffer.byteLength(fileContents));
-// sys.debug(client.requestBuffer.length);
-// assert.fail("the request buffer will not be forced to grow", "testGET (large; 0)");
-// }
+ var fileContents = fs.readFileSync(__filename, "binary");
var wasDebugMode = redisclient.debugMode;
redisclient.debugMode = false;
@@ -1763,7 +1757,7 @@ function testLargeGetSet() {
client.get('largetestfile', function (err, value) {
if (err) assert.fail(err, "testGET (large; 3)");
- checkEqual(value.utf8Slice(0, value.length), fileContents, "testGET (large; 4)");
+ checkEqual(value.binarySlice(0, value.length), fileContents, "testGET (large; 4)");
redisclient.debugMode = wasDebugMode;
testStoreAnImage();
});

0 comments on commit bd86792

Please sign in to comment.
Something went wrong with that request. Please try again.