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.

fix: Enhance file type detection in HTTP Request node (#11797)

stardust44104797d662
diff --git a/api/core/workflow/nodes/http_request/node.py b/api/core/workflow/nodes/http_request/node.py
index d040cc9f559..a0fc8acaefa 100644
--- a/api/core/workflow/nodes/http_request/node.py
+++ b/api/core/workflow/nodes/http_request/node.py
@@ -1,4 +1,5 @@
import logging
+import mimetypes
from collections.abc import Mapping, Sequence
from typing import Any
@@ -156,20 +157,24 @@ class HttpRequestNode(BaseNode[HttpRequestNodeData]):
def extract_files(self, url: str, response: Response) -> list[File]:
"""
- Extract files from response
+ Extract files from response by checking both Content-Type header and URL
"""
files = []
is_file = response.is_file
content_type = response.content_type
content = response.content
- if is_file and content_type:
+ if is_file:
+ # Guess file extension from URL or Content-Type header
+ filename = url.split("?")[0].split("/")[-1] or ""
+ mime_type = content_type or mimetypes.guess_type(filename)[0] or "application/octet-stream"
+
tool_file = ToolFileManager.create_file_by_raw(
user_id=self.user_id,
tenant_id=self.tenant_id,
conversation_id=None,
file_binary=content,
- mimetype=content_type,
+ mimetype=mime_type,
)
mapping = {