Further debugging on s3 api issues on Granian
This commit is contained in:
@@ -47,7 +47,6 @@ _request_counter = itertools.count(1)
|
||||
|
||||
|
||||
class _ChunkedTransferMiddleware:
|
||||
_logger = logging.getLogger("chunked_middleware")
|
||||
|
||||
def __init__(self, app):
|
||||
self.app = app
|
||||
@@ -72,6 +71,13 @@ class _ChunkedTransferMiddleware:
|
||||
if not is_streaming:
|
||||
return self.app(environ, start_response)
|
||||
|
||||
raw = environ.get("wsgi.input")
|
||||
if raw and hasattr(raw, "seek"):
|
||||
try:
|
||||
raw.seek(0)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
cl_int = 0
|
||||
try:
|
||||
cl_int = int(content_length) if content_length else 0
|
||||
@@ -80,8 +86,7 @@ class _ChunkedTransferMiddleware:
|
||||
|
||||
if cl_int <= 0:
|
||||
try:
|
||||
raw = environ["wsgi.input"]
|
||||
body = raw.read()
|
||||
body = raw.read() if raw else b""
|
||||
except Exception:
|
||||
body = b""
|
||||
if body:
|
||||
|
||||
@@ -1006,6 +1006,32 @@ def debug_upload():
|
||||
"request.content_length": request.content_length,
|
||||
}
|
||||
|
||||
raw = env.get("wsgi.input")
|
||||
if raw:
|
||||
try:
|
||||
info["wsgi_input_pos"] = raw.tell() if hasattr(raw, "tell") else "N/A"
|
||||
except Exception:
|
||||
info["wsgi_input_pos"] = "error"
|
||||
if hasattr(raw, "getvalue"):
|
||||
try:
|
||||
full = raw.getvalue()
|
||||
info["wsgi_input_getvalue_len"] = len(full)
|
||||
if full:
|
||||
info["wsgi_input_getvalue_hex"] = full[:200].hex()
|
||||
except Exception as e:
|
||||
info["wsgi_input_getvalue_error"] = str(e)
|
||||
try:
|
||||
if hasattr(raw, "seek"):
|
||||
raw.seek(0)
|
||||
seek_body = raw.read()
|
||||
info["wsgi_input_after_seek0_len"] = len(seek_body)
|
||||
if seek_body:
|
||||
info["wsgi_input_after_seek0_hex"] = seek_body[:200].hex()
|
||||
if hasattr(raw, "seek"):
|
||||
raw.seek(0)
|
||||
except Exception as e:
|
||||
info["wsgi_input_seek_read_error"] = str(e)
|
||||
|
||||
try:
|
||||
body = request.get_data(cache=False)
|
||||
info["body_length"] = len(body)
|
||||
|
||||
Reference in New Issue
Block a user