From 2e367f54228eb06bdcbfbf4ff6758cd37c7aec86 Mon Sep 17 00:00:00 2001 From: Matt Ranney Date: Fri, 17 Sep 2010 17:32:14 -0700 Subject: [PATCH] Send 0 length buffers properly. Still need to handle 0 length bulk data properly though. Whoops. --- index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 799274d3e9..6a6159c9a5 100644 --- a/index.js +++ b/index.js @@ -512,9 +512,14 @@ RedisClient.prototype.send_command = function () { } if (arg instanceof Buffer) { - stream.write("$" + arg.length + "\r\n"); - stream.write(arg); - stream.write("\r\n"); + if (arg.length === 0) { + console.log("Using empty string for 0 length buffer"); + stream.write("$0\r\n\r\n"); + } else { + stream.write("$" + arg.length + "\r\n"); + stream.write(arg); + stream.write("\r\n"); + } } else { stream.write("$" + arg.length + "\r\n" + arg + "\r\n"); } @@ -524,6 +529,7 @@ RedisClient.prototype.send_command = function () { RedisClient.prototype.end = function () { this.stream._events = {}; + this.connected = false; return this.stream.end(); };