forked from twitter/twemproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request twitter#406 from tom-dalton-fanduel/bugfix/redis-e…
…rror-response-parser Fix parsing bug when error body contains no spaces
- Loading branch information
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1920,6 +1920,9 @@ redis_parse_rsp(struct msg *r) | |
|
||
break; | ||
} | ||
if (ch == CR) { | ||
p -= 1; | ||
} | ||
state = SW_RUNTO_CRLF; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python | ||
#coding: utf-8 | ||
|
||
from unittest import TestCase | ||
|
||
from redis import Redis, ResponseError | ||
|
||
from common import * | ||
|
||
|
||
class LuaReturnErrorTestCase(TestCase): | ||
|
||
def test_lua_return_error(self): | ||
"""Test the error described on issue 404 is fixed. | ||
https://github.com/twitter/twemproxy/issues/404 | ||
""" | ||
r = getconn() | ||
p = r.pipeline(transaction=False) | ||
|
||
p.set("test_key", "bananas!") | ||
p.eval('return {err="dummyerror"}', 1, "dummy_key") | ||
p.get("test_key") | ||
|
||
set_result, eval_result, get_result = p.execute(raise_on_error=False) | ||
|
||
self.assertTrue(set_result) | ||
|
||
self.assertIsInstance(eval_result, ResponseError) | ||
self.assertEqual(eval_result.message, "dummyerror") | ||
|
||
self.assertEqual(get_result, "bananas!") |