|
@@ -3,6 +3,7 @@ from mimetypes import guess_extension
|
|
|
from os import path
|
|
|
from typing import cast
|
|
|
|
|
|
+from configs import dify_config
|
|
|
from core.app.segments import parser
|
|
|
from core.file.file_obj import FileTransferMethod, FileType, FileVar
|
|
|
from core.tools.tool_file_manager import ToolFileManager
|
|
@@ -11,9 +12,6 @@ from core.workflow.entities.node_entities import NodeRunResult, NodeType
|
|
|
from core.workflow.entities.variable_pool import VariablePool
|
|
|
from core.workflow.nodes.base_node import BaseNode
|
|
|
from core.workflow.nodes.http_request.entities import (
|
|
|
- MAX_CONNECT_TIMEOUT,
|
|
|
- MAX_READ_TIMEOUT,
|
|
|
- MAX_WRITE_TIMEOUT,
|
|
|
HttpRequestNodeData,
|
|
|
HttpRequestNodeTimeout,
|
|
|
)
|
|
@@ -21,9 +19,9 @@ from core.workflow.nodes.http_request.http_executor import HttpExecutor, HttpExe
|
|
|
from models.workflow import WorkflowNodeExecutionStatus
|
|
|
|
|
|
HTTP_REQUEST_DEFAULT_TIMEOUT = HttpRequestNodeTimeout(
|
|
|
- connect=min(10, MAX_CONNECT_TIMEOUT),
|
|
|
- read=min(60, MAX_READ_TIMEOUT),
|
|
|
- write=min(20, MAX_WRITE_TIMEOUT),
|
|
|
+ connect=min(10, dify_config.HTTP_REQUEST_MAX_CONNECT_TIMEOUT),
|
|
|
+ read=min(60, dify_config.HTTP_REQUEST_MAX_READ_TIMEOUT),
|
|
|
+ write=min(20, dify_config.HTTP_REQUEST_MAX_WRITE_TIMEOUT),
|
|
|
)
|
|
|
|
|
|
|
|
@@ -43,9 +41,9 @@ class HttpRequestNode(BaseNode):
|
|
|
'body': {'type': 'none'},
|
|
|
'timeout': {
|
|
|
**HTTP_REQUEST_DEFAULT_TIMEOUT.model_dump(),
|
|
|
- 'max_connect_timeout': MAX_CONNECT_TIMEOUT,
|
|
|
- 'max_read_timeout': MAX_READ_TIMEOUT,
|
|
|
- 'max_write_timeout': MAX_WRITE_TIMEOUT,
|
|
|
+ 'max_connect_timeout': dify_config.HTTP_REQUEST_MAX_CONNECT_TIMEOUT,
|
|
|
+ 'max_read_timeout': dify_config.HTTP_REQUEST_MAX_READ_TIMEOUT,
|
|
|
+ 'max_write_timeout': dify_config.HTTP_REQUEST_MAX_WRITE_TIMEOUT,
|
|
|
},
|
|
|
},
|
|
|
}
|
|
@@ -92,17 +90,18 @@ class HttpRequestNode(BaseNode):
|
|
|
},
|
|
|
)
|
|
|
|
|
|
- def _get_request_timeout(self, node_data: HttpRequestNodeData) -> HttpRequestNodeTimeout:
|
|
|
+ @staticmethod
|
|
|
+ def _get_request_timeout(node_data: HttpRequestNodeData) -> HttpRequestNodeTimeout:
|
|
|
timeout = node_data.timeout
|
|
|
if timeout is None:
|
|
|
return HTTP_REQUEST_DEFAULT_TIMEOUT
|
|
|
|
|
|
- timeout.connect = timeout.connect or HTTP_REQUEST_DEFAULT_TIMEOUT.connect
|
|
|
- timeout.connect = min(timeout.connect, MAX_CONNECT_TIMEOUT)
|
|
|
- timeout.read = timeout.read or HTTP_REQUEST_DEFAULT_TIMEOUT.read
|
|
|
- timeout.read = min(timeout.read, MAX_READ_TIMEOUT)
|
|
|
- timeout.write = timeout.write or HTTP_REQUEST_DEFAULT_TIMEOUT.write
|
|
|
- timeout.write = min(timeout.write, MAX_WRITE_TIMEOUT)
|
|
|
+ timeout.connect = min(timeout.connect or HTTP_REQUEST_DEFAULT_TIMEOUT.connect,
|
|
|
+ dify_config.HTTP_REQUEST_MAX_CONNECT_TIMEOUT)
|
|
|
+ timeout.read = min(timeout.read or HTTP_REQUEST_DEFAULT_TIMEOUT.read,
|
|
|
+ dify_config.HTTP_REQUEST_MAX_READ_TIMEOUT)
|
|
|
+ timeout.write = min(timeout.write or HTTP_REQUEST_DEFAULT_TIMEOUT.write,
|
|
|
+ dify_config.HTTP_REQUEST_MAX_WRITE_TIMEOUT)
|
|
|
return timeout
|
|
|
|
|
|
@classmethod
|