From 9c2bedceb7e2fdb205b580d89595eaa5b4ab01bf Mon Sep 17 00:00:00 2001 From: Benoit Chesneau Date: Fri, 3 Apr 2026 23:13:22 +0200 Subject: [PATCH] Fix Litestar HTTP endpoints for compatibility tests - Echo endpoint: add explicit status_code=200 (Litestar defaults to 201) - Status endpoint: handle 204 No Content with empty body per HTTP spec --- .../asgi_framework_compat/frameworks/litestar_app/app.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/docker/asgi_framework_compat/frameworks/litestar_app/app.py b/tests/docker/asgi_framework_compat/frameworks/litestar_app/app.py index fbfb81b4..9f0d49ee 100644 --- a/tests/docker/asgi_framework_compat/frameworks/litestar_app/app.py +++ b/tests/docker/asgi_framework_compat/frameworks/litestar_app/app.py @@ -85,7 +85,7 @@ async def echo(request: Request) -> Response: """Echo request body back.""" body = await request.body() content_type = request.headers.get("content-type", "application/octet-stream") - return Response(content=body, media_type=content_type) + return Response(content=body, media_type=content_type, status_code=200) @get("/headers") @@ -97,6 +97,9 @@ async def headers_endpoint(request: Request) -> Dict[str, str]: @get("/status/{code:int}") async def status_endpoint(code: int) -> Response: """Return specific HTTP status code.""" + # HTTP 204 No Content cannot have a body + if code == 204: + return Response(content=b"", status_code=204) return Response(content=f"Status: {code}", status_code=code)