PR#3289: log content-length when we get an error reading request

Merges #3289
https://pagure.io/koji/pull-request/3289

Fixes: #3288
https://pagure.io/koji/issue/3288
rfe: log content length on request read errors
This commit is contained in:
Tomas Kopecek 2022-05-04 15:19:45 +02:00
commit b0a2875f7e
2 changed files with 8 additions and 4 deletions

View file

@ -15515,10 +15515,12 @@ def handle_upload(environ):
str_e = str(e)
logger.error(f"Error reading upload. Offset {offset}+{size}, path {fn}")
if 'timeout' in str_e:
logger.exception("Timed out reading input stream")
logger.exception("Timed out reading input stream. "
f"Content-Length: {context.environ.get('CONTENT_LENGTH')}")
raise RequestTimeout(str_e)
else:
logger.exception("Error reading input stream")
logger.exception("Error reading input stream. "
f"Content-Length: {context.environ.get('CONTENT_LENGTH')}")
raise BadRequest(str_e)
if not chunk:
break

View file

@ -219,10 +219,12 @@ class ModXMLRPCRequestHandler(object):
except OSError as e:
str_e = str(e)
if 'timeout' in str_e:
self.logger.exception("Timed out reading input stream")
self.logger.exception("Timed out reading input stream. "
f"Content-Length: {context.environ.get('CONTENT_LENGTH')}")
raise RequestTimeout(str_e)
else:
self.logger.exception("Error reading input stream")
self.logger.exception("Error reading input stream. "
f"Content-Length: {context.environ.get('CONTENT_LENGTH')}")
raise BadRequest(str_e)
if not chunk:
break