From 0e0869b4f22a202c73cc85f7f0eb0621d51953c3 Mon Sep 17 00:00:00 2001 From: Marcelo Trylesinski Date: Sat, 14 Dec 2024 23:26:18 +0100 Subject: [PATCH] Add `content-length` to 500 response in wsproto --- uvicorn/protocols/websockets/wsproto_impl.py | 1 + 1 file changed, 1 insertion(+) diff --git a/uvicorn/protocols/websockets/wsproto_impl.py b/uvicorn/protocols/websockets/wsproto_impl.py index 072dec942..828afe512 100644 --- a/uvicorn/protocols/websockets/wsproto_impl.py +++ b/uvicorn/protocols/websockets/wsproto_impl.py @@ -224,6 +224,7 @@ def send_500_response(self) -> None: headers: list[tuple[bytes, bytes]] = [ (b"content-type", b"text/plain; charset=utf-8"), (b"connection", b"close"), + (b"content-length", b"21"), ] output = self.conn.send(wsproto.events.RejectConnection(status_code=500, headers=headers, has_body=True)) output += self.conn.send(wsproto.events.RejectData(data=b"Internal Server Error"))