1
0
mirror of https://github.com/redis/node-redis.git synced 2025-08-06 02:15:48 +03:00

Send 0 length buffers properly.

Still need to handle 0 length bulk data properly though.  Whoops.
This commit is contained in:
Matt Ranney
2010-09-17 17:32:14 -07:00
parent 13e7efc531
commit 2e367f5422

View File

@@ -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();
};