Add support for bytes-like requests

Under some circumstances, some requests may be a bytes-like object.
This patchset adds support for them.

Change-Id: I274ddd586604f93c1335e8511f5dd1773736ed4d
This commit is contained in:
Luciano Lo Giudice 2023-10-09 17:56:16 -03:00
parent 77f73ae97c
commit 5d62e13ae3
1 changed files with 2 additions and 0 deletions

View File

@ -106,6 +106,8 @@ def decode_req_encode_rsp(f):
"""Decorator to decode incoming requests and encode responses."""
def decode_inner(req):
if isinstance(req, bytes):
req = req.decode('utf-8')
return json.dumps(f(json.loads(req)))
return decode_inner