Skip to content

Commit

Permalink
another fix for aio-libs#294
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-eri authored Jun 19, 2018
1 parent fa10335 commit 8ba8a94
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions aiohttp_session/redis_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, redis_pool, *, cookie_name="AIOHTTP_SESSION",
domain=None, max_age=None, path='/',
secure=None, httponly=True,
key_factory=lambda: uuid.uuid4().hex,
encoder=json.dumps, decoder=json.loads):
encoder=json.dumps, decoder=json.loads, str_decode=True):
super().__init__(cookie_name=cookie_name, domain=domain,
max_age=max_age, path=path, secure=secure,
httponly=httponly,
Expand All @@ -38,6 +38,7 @@ def __init__(self, redis_pool, *, cookie_name="AIOHTTP_SESSION",
raise TypeError("Expexted aioredis.commands.Redis got {}".format(
type(redis_pool)))
self._redis = redis_pool
self.str_decode = str_decode

async def load_session(self, request):
cookie = self.load_cookie(request)
Expand All @@ -50,7 +51,8 @@ async def load_session(self, request):
if data is None:
return Session(None, data=None,
new=True, max_age=self.max_age)
data = data.decode('utf-8')
if self.str_decode:
data = data.decode('utf-8')
try:
data = self._decoder(data)
except ValueError:
Expand Down

0 comments on commit 8ba8a94

Please sign in to comment.