From 4e04784f9b83a85f29c899c672d261e8e763ed9a Mon Sep 17 00:00:00 2001 From: 0880 <98263509+0880880@users.noreply.github.com> Date: Sat, 17 Jan 2026 18:31:27 +0330 Subject: [PATCH] Allow bytes content HTTPRepsonse --- slow/slow.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/slow/slow.py b/slow/slow.py index ed04159..55e266c 100644 --- a/slow/slow.py +++ b/slow/slow.py @@ -260,12 +260,14 @@ class App: def HTTPResponse( request: Request, - content: str, + content: str | bytes, status=200, content_type="text/plain; charset=utf-8", headers=[], ) -> bytes: - content_bytes = content.encode(encoding="utf-8") + content_bytes = content + if isinstance(content, str): + content_bytes = content.encode(encoding="utf-8") head: str = f"HTTP/1.1 {status} {http.client.responses.get(status, 'Unkown Status Code')}\r\nContent-Type: {content_type}\r\nContent-Length: {len(content_bytes)}\r\n" if ( "origin" in request.headers