Skip to content

Commit

Permalink
Fixed zero-length mutlibulk replies
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Sep 17, 2010
1 parent c0f7a40 commit d7c5fc6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ RedisReplyParser.prototype.execute = function (incoming_buf) {
this.multi_bulk_length = parseInt(small_toString(this.tmp_buffer), 10);
this.multi_bulk_replies = [];
this.state = "type";
if (0 == this.multi_bulk_length) {
this.send_reply([]);
}
} else {
this.emit("error", new Error("didn't see LF after NL reading multi bulk count"));
this.state = "type"; // try to start over with next data chunk
Expand Down
6 changes: 3 additions & 3 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,10 @@ tests.KEYS = function () {
});
};

tests.KEYS_EMPTY = function () {
var name = "KEYS_EMPTY";
tests.MULTIBULK_ZERO_LENGTH = function () {
var name = "MULTIBULK_ZERO_LENGTH";
client.KEYS(['users:*'], function(err, results){
assert.strictEqual(null, err, 'error on empty KEYS');
assert.strictEqual(null, err, 'error on empty multibulk reply');
assert.strictEqual(0, results.length);
next(name);
});
Expand Down

0 comments on commit d7c5fc6

Please sign in to comment.