From 3d8298724039821f8307e4f251555ea7f69fc06c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 28 Dec 2025 03:25:10 +0000 Subject: [PATCH 1/2] Initial plan From 6ec32b1dd875f73bb86d42498bd00bb17863ae89 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 28 Dec 2025 03:27:54 +0000 Subject: [PATCH 2/2] refactor: move gzip import to module level in middleware Co-authored-by: JacobCoffee <45884264+JacobCoffee@users.noreply.github.com> --- src/debug_toolbar/litestar/middleware.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/debug_toolbar/litestar/middleware.py b/src/debug_toolbar/litestar/middleware.py index b306323..eeb62f3 100644 --- a/src/debug_toolbar/litestar/middleware.py +++ b/src/debug_toolbar/litestar/middleware.py @@ -2,6 +2,7 @@ from __future__ import annotations +import gzip import logging import re import time @@ -490,8 +491,6 @@ def _inject_toolbar(self, body: bytes, context: RequestContext, content_encoding Tuple of (modified body, content_encoding to use). If gzip was decompressed, returns uncompressed body with empty encoding. """ - import gzip - # Handle gzip-compressed responses is_gzipped = content_encoding.lower() == "gzip" if is_gzipped: