gar1t/erlang-redis — pull request #6 by climvalencia (2014-11-07 08:30:10+00:00)
Title: Correctly return remaining data after parsing RESP array

I found a bug in the `redis_reply:data/1` parser.

If the redis server should return a reply array followed by any data (PONG in the example below), the `redis_reply` parser will incorrectly include PONG in the list of values, then finally return with a pending status.

```erlang
1> redis_reply:data(<<"*2\r\n$4\r\nmem2\r\n$4\r\nmem1\r\n+PONG\r\n">>, {unknown, <<>>}).
{pending,{multi,2,
["PONG",<<"mem1">>,<<"mem2">>],
{unknown,<<>>}}}
```

This results in `redis_client` (the calling process) ending up with a broken state that never sends back the replies.

Applying this fix should return the correct values:
```erlang
1> redis_reply:data(<<"*2\r\n$4\r\nmem2\r\n$4\r\nmem1\r\n+PONG\r\n">>, {unknown, <<>>}).
{{value,{ok,[<<"mem2">>,<<"mem1">>]}},
{unknown,<<"+PONG\r\n">>}}
```