Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

feat(http-request-executor): enhance file handling in HTTP requests (#9944)

-LAN-4da0b706948a
diff --git a/api/core/workflow/nodes/http_request/executor.py b/api/core/workflow/nodes/http_request/executor.py
index 0270d7e0fd0..6872478299f 100644
--- a/api/core/workflow/nodes/http_request/executor.py
+++ b/api/core/workflow/nodes/http_request/executor.py
@@ -33,7 +33,7 @@ class Executor:
params: Mapping[str, str] | None
content: str | bytes | None
data: Mapping[str, Any] | None
- files: Mapping[str, bytes] | None
+ files: Mapping[str, tuple[str | None, bytes, str]] | None
json: Any
headers: dict[str, str]
auth: HttpRequestNodeAuthorization
@@ -141,7 +141,11 @@ class Executor:
files = {k: self.variable_pool.get_file(selector) for k, selector in file_selectors.items()}
files = {k: v for k, v in files.items() if v is not None}
files = {k: variable.value for k, variable in files.items()}
- files = {k: file_manager.download(v) for k, v in files.items() if v.related_id is not None}
+ files = {
+ k: (v.filename, file_manager.download(v), v.mime_type or "application/octet-stream")
+ for k, v in files.items()
+ if v.related_id is not None
+ }
self.data = form_data
self.files = files
diff --git a/api/tests/unit_tests/core/workflow/nodes/test_http_request_node.py b/api/tests/unit_tests/core/workflow/nodes/test_http_request_node.py
index 2a5fda48b1f..720037d05fb 100644
--- a/api/tests/unit_tests/core/workflow/nodes/test_http_request_node.py
+++ b/api/tests/unit_tests/core/workflow/nodes/test_http_request_node.py
@@ -192,7 +192,7 @@ def test_http_request_node_form_with_file(monkeypatch):
def attr_checker(*args, **kwargs):
assert kwargs["data"] == {"name": "test"}
- assert kwargs["files"] == {"file": b"test"}
+ assert kwargs["files"] == {"file": (None, b"test", "application/octet-stream")}
return httpx.Response(200, content=b"")
monkeypatch.setattr(