Only parse requests and responses as msgpack if they were not JSON

pull/118/head
alufers 11 months ago
parent dcf1bd7694
commit b4f301f44c

@ -242,7 +242,8 @@ def main(override_args: Optional[Sequence[str]] = None):
except json.decoder.JSONDecodeError: except json.decoder.JSONDecodeError:
pass pass
# try to parse the body as msgpack # try to parse the body as msgpack, if it's not json
if body_val is None:
try: try:
body_val = msgpack.loads(req.get_request_body()) body_val = msgpack.loads(req.get_request_body())
content_type = "application/msgpack" content_type = "application/msgpack"
@ -298,7 +299,8 @@ def main(override_args: Optional[Sequence[str]] = None):
except json.decoder.JSONDecodeError: except json.decoder.JSONDecodeError:
response_parsed = None response_parsed = None
# try parsing the response as msgpack if response_parsed is None:
# try parsing the response as msgpack, if it's not json
try: try:
response_parsed = msgpack.loads(response_body) response_parsed = msgpack.loads(response_body)
response_content_type = "application/msgpack" response_content_type = "application/msgpack"

Loading…
Cancel
Save