summaryrefslogtreecommitdiff
path: root/redis/client.py
diff options
context:
space:
mode:
authorChayim I. Kirshen <c@kirshen.com>2021-11-21 13:17:31 +0200
committerChayim I. Kirshen <c@kirshen.com>2021-11-21 13:17:31 +0200
commit1448a65e656a270caf4c6d3ba4eee5de04d0c4e1 (patch)
tree3b94bf968ef0d0d8b9820f8e8c390cab752df07a /redis/client.py
parentd2b233384458869270352b8c99ca682ae480da5f (diff)
downloadredis-py-ck-binary-responses.tar.gz
Adding support for non-decodable commandsck-binary-responses
Some commands (i.e DUMP) should never have their response decoded, as they return binaries, not encoded blobs fixes #1254
Diffstat (limited to 'redis/client.py')
-rwxr-xr-xredis/client.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/redis/client.py b/redis/client.py
index dc6693d..b218c1d 100755
--- a/redis/client.py
+++ b/redis/client.py
@@ -27,6 +27,9 @@ from redis.utils import safe_str, str_if_bytes
SYM_EMPTY = b''
EMPTY_RESPONSE = 'EMPTY_RESPONSE'
+# some responses (ie. dump) are binary, and just meant to never be decoded
+NEVER_DECODE = 'NEVER_DECODE'
+
def timestamp_to_datetime(response):
"Converts a unix timestamp to a Python datetime object"
@@ -1081,7 +1084,10 @@ class Redis(RedisModuleCommands, CoreCommands, SentinelCommands, object):
def parse_response(self, connection, command_name, **options):
"Parses a response from the Redis server"
try:
- response = connection.read_response()
+ if NEVER_DECODE in options:
+ response = connection.read_response(disable_decoding=True)
+ else:
+ response = connection.read_response()
except ResponseError:
if EMPTY_RESPONSE in options:
return options[EMPTY_RESPONSE]