From c5d4b8ff0aa154504f842d61ac74c3c18ccc457b Mon Sep 17 00:00:00 2001 From: jstzwj <1103870790@qq.com> Date: Mon, 2 Sep 2024 04:51:52 +0800 Subject: [PATCH] file get bug fix --- olah/proxy/files.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/olah/proxy/files.py b/olah/proxy/files.py index 5d2a5c8..3cef661 100644 --- a/olah/proxy/files.py +++ b/olah/proxy/files.py @@ -430,11 +430,27 @@ async def _file_realtime_stream( headers=request_headers, allow_cache=allow_cache, ) - if status_code != 200: - yield status_code - yield head_info - yield content + if status_code == 404: + yield 404 + yield { + "x-error-code": "EntryNotFound", + "x-error-message": "Entry not found", + } + yield "Entry not found" return + if status_code != 200: + if method.lower() == "head": + yield status_code + yield head_info + yield content + return + elif method.lower() == "get": + yield status_code + yield head_info + yield content + return + else: + raise Exception("Invalid method in _file_realtime_stream parameter.") except httpx.ConnectError: yield 504 yield {}