Fix #93: Fix incorrect Content-Length headers causing truncated responses and timeouts #122
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "typosaurus/ticket-93"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Resolves #93.
Plan
Implementation Plan
Root cause identified: Double compression – nginx (
gzip on,gzip_proxied any) re-compresses the already-compressed response from Python’sGZipMiddleware, leading to metadata corruption and the reported Content-Length mismatch.Fix: Remove
GZipMiddlewarefrom the Python application. nginx (which is always deployed in production) already handles compression correctly for all proxy responses. This eliminates the double-compression anti-pattern without losing compression at the edge.Changes to make
/workspace/repo/main.py(line approximately 614)Remove the middleware registration line:
/workspace/repo/main.py(top of file)Remove the corresponding import:
If this import is used elsewhere (unlikely), leave it; otherwise delete it.
No other files need modification.
nginx/nginx.conf.template) remains unchanged –gzip onalready covers all response types.Verifying correctness
Execution steps
main.py.from starlette.middleware.gzip import GZipMiddlewareline.app.add_middleware(GZipMiddleware, minimum_size=1000)line.pip install -e '.[dev]' -qto ensure dependencies are installed.python -m pytestto confirm all tests pass.ruff check .or equivalent) to confirm no new violations.Definition of Done
GZipMiddlewareimport and middleware registration are removed frommain.py.pip install -e '.[dev]' -q && python -m pytestContent-Encoding: gzipwhen running without nginx; production nginx continues to compress responses correctly.Opened automatically by Typosaurus.
feb1963aadto63366bb240Checkout
From your project repository, check out a new branch and test the changes.