From ee1f14621a5c556e83e464e95143a45d7434b4cc Mon Sep 17 00:00:00 2001 From: Jyong <76649700+JohnJyong@users.noreply.github.com> Date: Tue, 19 Nov 2024 21:03:01 +0800 Subject: [PATCH] fix httpx doesn't support stream parameter (#10859) --- api/core/helper/ssrf_proxy.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/core/helper/ssrf_proxy.py b/api/core/helper/ssrf_proxy.py index 374bd9d57bc4b1..80f01fa12b3544 100644 --- a/api/core/helper/ssrf_proxy.py +++ b/api/core/helper/ssrf_proxy.py @@ -39,6 +39,7 @@ def make_request(method, url, max_retries=SSRF_DEFAULT_MAX_RETRIES, **kwargs): ) retries = 0 + stream = kwargs.pop("stream", False) while retries <= max_retries: try: if dify_config.SSRF_PROXY_ALL_URL: @@ -52,6 +53,8 @@ def make_request(method, url, max_retries=SSRF_DEFAULT_MAX_RETRIES, **kwargs): response = client.request(method=method, url=url, **kwargs) if response.status_code not in STATUS_FORCELIST: + if stream: + return response.iter_bytes() return response else: logging.warning(f"Received status code {response.status_code} for URL {url} which is in the force list")