From 76bec6ce7fb51e57ce62b65f5f1933e254dc0a40 Mon Sep 17 00:00:00 2001 From: Yeuoly <45712896+Yeuoly@users.noreply.github.com> Date: Tue, 7 May 2024 12:07:56 +0800 Subject: [PATCH] feat: add http node max size env (#4137) --- api/.env.example | 2 ++ api/core/workflow/nodes/http_request/http_executor.py | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/api/.env.example b/api/.env.example index 30bbf331a4..01326a0cc8 100644 --- a/api/.env.example +++ b/api/.env.example @@ -163,6 +163,8 @@ API_TOOL_DEFAULT_READ_TIMEOUT=60 HTTP_REQUEST_MAX_CONNECT_TIMEOUT=300 HTTP_REQUEST_MAX_READ_TIMEOUT=600 HTTP_REQUEST_MAX_WRITE_TIMEOUT=600 +HTTP_REQUEST_NODE_MAX_BINARY_SIZE=10485760 # 10MB +HTTP_REQUEST_NODE_MAX_TEXT_SIZE=1048576 # 1MB # Log file path LOG_FILE= diff --git a/api/core/workflow/nodes/http_request/http_executor.py b/api/core/workflow/nodes/http_request/http_executor.py index c2beb7a383..1fb73afd12 100644 --- a/api/core/workflow/nodes/http_request/http_executor.py +++ b/api/core/workflow/nodes/http_request/http_executor.py @@ -1,4 +1,5 @@ import json +import os from copy import deepcopy from random import randint from typing import Any, Optional, Union @@ -13,10 +14,10 @@ from core.workflow.entities.variable_pool import ValueType, VariablePool from core.workflow.nodes.http_request.entities import HttpRequestNodeData from core.workflow.utils.variable_template_parser import VariableTemplateParser -MAX_BINARY_SIZE = 1024 * 1024 * 10 # 10MB -READABLE_MAX_BINARY_SIZE = '10MB' -MAX_TEXT_SIZE = 1024 * 1024 // 10 # 0.1MB -READABLE_MAX_TEXT_SIZE = '0.1MB' +MAX_BINARY_SIZE = int(os.environ.get('HTTP_REQUEST_NODE_MAX_BINARY_SIZE', str(1024 * 1024 * 10))) # 10MB +READABLE_MAX_BINARY_SIZE = f'{MAX_BINARY_SIZE / 1024 / 1024:.2f}MB' +MAX_TEXT_SIZE = int(os.environ.get('HTTP_REQUEST_NODE_MAX_TEXT_SIZE', str(1024 * 1024))) # 10MB # 1MB +READABLE_MAX_TEXT_SIZE = f'{MAX_TEXT_SIZE / 1024 / 1024:.2f}MB' class HttpExecutorResponse: