support nil bulk string

ewwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
master
Jordan Orelli 11 years ago
parent e9f07e3128
commit fdac1f52ee

@ -101,6 +101,9 @@ func readBulkString(prefix []byte, r io.Reader) (value, error) {
return nil, fmt.Errorf("unable to read bulkstring in redis protocol: bad prefix: %v", err) return nil, fmt.Errorf("unable to read bulkstring in redis protocol: bad prefix: %v", err)
} }
if n == -1 {
return nil, nil
}
n += 2 n += 2
b := make([]byte, n) b := make([]byte, n)
n_read, err := r.Read(b) n_read, err := r.Read(b)

@ -47,6 +47,7 @@ var valueTests = []valueTest{
{"-one two ", Error("one two ")}, // trailing space {"-one two ", Error("one two ")}, // trailing space
{"- one two", Error(" one two")}, // leading space {"- one two", Error(" one two")}, // leading space
{"$-1\r\n", nil},
{"$0\r\n\r\n", BulkString("")}, // is this even a thing? {"$0\r\n\r\n", BulkString("")}, // is this even a thing?
{"$1\r\nx\r\n", BulkString("x")}, {"$1\r\nx\r\n", BulkString("x")},
{"$4\r\netsy\r\n", BulkString("etsy")}, {"$4\r\netsy\r\n", BulkString("etsy")},

Loading…
Cancel
Save