Compare commits
1 Commits
014cdd80e2
...
4e04784f9b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e04784f9b |
@@ -260,12 +260,14 @@ class App:
|
|||||||
|
|
||||||
def HTTPResponse(
|
def HTTPResponse(
|
||||||
request: Request,
|
request: Request,
|
||||||
content: str,
|
content: str | bytes,
|
||||||
status=200,
|
status=200,
|
||||||
content_type="text/plain; charset=utf-8",
|
content_type="text/plain; charset=utf-8",
|
||||||
headers=[],
|
headers=[],
|
||||||
) -> bytes:
|
) -> 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"
|
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 (
|
if (
|
||||||
"origin" in request.headers
|
"origin" in request.headers
|
||||||
|
|||||||
Reference in New Issue
Block a user