From 50a6b8462d908f3feff1d58c995386944aa77883 Mon Sep 17 00:00:00 2001 From: Peter Bieringer Date: Sat, 4 Oct 2025 11:48:08 +0200 Subject: [PATCH] log size of answer if given --- radicale/app/__init__.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/radicale/app/__init__.py b/radicale/app/__init__.py index 0fcbd328..ce948e82 100644 --- a/radicale/app/__init__.py +++ b/radicale/app/__init__.py @@ -164,6 +164,7 @@ class Application(ApplicationPartDelete, ApplicationPartHead, answer: Union[None, str, bytes]) -> _IntermediateResponse: """Helper to create response from internal types.WSGIResponse""" headers = dict(headers) + content_encoding = "plain" # Set content length answers = [] if answer is not None: @@ -183,6 +184,7 @@ class Application(ApplicationPartDelete, ApplicationPartHead, zcomp = zlib.compressobj(wbits=16 + zlib.MAX_WBITS) answer = zcomp.compress(answer) + zcomp.flush() headers["Content-Encoding"] = "gzip" + content_encoding = "gzip" headers["Content-Length"] = str(len(answer)) answers.append(answer) @@ -194,9 +196,14 @@ class Application(ApplicationPartDelete, ApplicationPartHead, time_end = datetime.datetime.now() status_text = "%d %s" % ( status, client.responses.get(status, "Unknown")) - logger.info("%s response status for %r%s in %.3f seconds: %s", - request_method, unsafe_path, depthinfo, - (time_end - time_begin).total_seconds(), status_text) + if answer is not None: + logger.info("%s response status for %r%s in %.3f seconds %s %s bytes: %s", + request_method, unsafe_path, depthinfo, + (time_end - time_begin).total_seconds(), content_encoding, str(len(answer)), status_text) + else: + logger.info("%s response status for %r%s in %.3f seconds: %s", + request_method, unsafe_path, depthinfo, + (time_end - time_begin).total_seconds(), status_text) # Return response content return status_text, list(headers.items()), answers