mirror of
https://github.com/frappe/gunicorn.git
synced 2026-07-02 18:51:31 +08:00
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
This commit is contained in:
parent
cbba5cb302
commit
9c2bedceb7
@ -85,7 +85,7 @@ async def echo(request: Request) -> Response:
|
|||||||
"""Echo request body back."""
|
"""Echo request body back."""
|
||||||
body = await request.body()
|
body = await request.body()
|
||||||
content_type = request.headers.get("content-type", "application/octet-stream")
|
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")
|
@get("/headers")
|
||||||
@ -97,6 +97,9 @@ async def headers_endpoint(request: Request) -> Dict[str, str]:
|
|||||||
@get("/status/{code:int}")
|
@get("/status/{code:int}")
|
||||||
async def status_endpoint(code: int) -> Response:
|
async def status_endpoint(code: int) -> Response:
|
||||||
"""Return specific HTTP status code."""
|
"""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)
|
return Response(content=f"Status: {code}", status_code=code)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user