From 613ef6deabcdb372f786dcecc2bd0a8cf002bb13 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Fri, 7 Jan 2022 16:04:00 +0000 Subject: [PATCH] Gateway: Properly report zlib.decompress() errors to uploaders This also adds some debug/error logging to the code path. --- src/eddn/Gateway.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/eddn/Gateway.py b/src/eddn/Gateway.py index 9aee4f5..63e8d3e 100644 --- a/src/eddn/Gateway.py +++ b/src/eddn/Gateway.py @@ -130,14 +130,18 @@ def get_decompressed_message(): content_encoding = request.headers.get('Content-Encoding', '') if content_encoding in ['gzip', 'deflate']: + logger.debug('Content-Encoding of gzip or deflate...') # Compressed request. We have to decompress the body, then figure out # if it's form-encoded. try: # Auto header checking. + logger.debug('Trying zlib.decompress (15 + 32)...') message_body = zlib.decompress(request.body.read(), 15 + 32) except zlib.error: + logger.error('zlib.error, trying zlib.decompress (-15)') # Negative wbits suppresses adler32 checksumming. message_body = zlib.decompress(request.body.read(), -15) + logger.debug('Resulting message_body:\n%s\n' % (message_body)) # At this point, we're not sure whether we're dealing with a straight # un-encoded POST body, or a form-encoded POST. Attempt to parse the @@ -268,7 +272,7 @@ def upload(): print('Logging of "gzip error" failed: %s' % (e.message)) pass - return exc.message + return 'FAIL: zlib.error: ' + exc.message except MalformedUploadError as exc: # They probably sent an encoded POST, but got the key/val wrong.