From afb38d628be6467031ee8c15f9106a2e54331911 Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Fri, 22 Nov 2024 14:19:51 +0100 Subject: [PATCH] typos --- app/middleware.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/middleware.py b/app/middleware.py index db97bb0..2e7ce27 100644 --- a/app/middleware.py +++ b/app/middleware.py @@ -23,17 +23,17 @@ class PatchMalformedJsonMiddleware(BaseHTTPMiddleware): if self.enabled and content_type == 'application/json': logger.debug(f'Using Request-Patch because "PatchMalformedJsonMiddleware" is enabled!') + body = body.decode() # try to fix json - body = body.decode() try: j = json.loads(body) self.fix_mac_address_list_length(j=j, size=1) except json.decoder.JSONDecodeError: logger.warning(f'Malformed json received! Try to fix it.') - s = PatchMalformedJsonMiddleware.fix_json(body) - logger.debug(f'Fixed JSON: "{s}"') - j = json.loads(s) # ensure json is now valid + body = PatchMalformedJsonMiddleware.fix_json(body) + logger.debug(f'Fixed JSON: "{body}"') + j = json.loads(body) # ensure json is now valid j = self.fix_mac_address_list_length(j=j, size=1) # set new body request._body = json.dumps(j).encode('utf-8')