mirror of
https://github.com/EDCD/EDDN.git
synced 2025-06-07 19:03:10 +03:00
Gateway: Properly report zlib.decompress() errors to uploaders
This also adds some debug/error logging to the code path.
This commit is contained in:
parent
e58dc3b5d2
commit
613ef6deab
@ -130,14 +130,18 @@ def get_decompressed_message():
|
|||||||
content_encoding = request.headers.get('Content-Encoding', '')
|
content_encoding = request.headers.get('Content-Encoding', '')
|
||||||
|
|
||||||
if content_encoding in ['gzip', 'deflate']:
|
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
|
# Compressed request. We have to decompress the body, then figure out
|
||||||
# if it's form-encoded.
|
# if it's form-encoded.
|
||||||
try:
|
try:
|
||||||
# Auto header checking.
|
# Auto header checking.
|
||||||
|
logger.debug('Trying zlib.decompress (15 + 32)...')
|
||||||
message_body = zlib.decompress(request.body.read(), 15 + 32)
|
message_body = zlib.decompress(request.body.read(), 15 + 32)
|
||||||
except zlib.error:
|
except zlib.error:
|
||||||
|
logger.error('zlib.error, trying zlib.decompress (-15)')
|
||||||
# Negative wbits suppresses adler32 checksumming.
|
# Negative wbits suppresses adler32 checksumming.
|
||||||
message_body = zlib.decompress(request.body.read(), -15)
|
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
|
# 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
|
# 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))
|
print('Logging of "gzip error" failed: %s' % (e.message))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return exc.message
|
return 'FAIL: zlib.error: ' + exc.message
|
||||||
|
|
||||||
except MalformedUploadError as exc:
|
except MalformedUploadError as exc:
|
||||||
# They probably sent an encoded POST, but got the key/val wrong.
|
# They probably sent an encoded POST, but got the key/val wrong.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user