enhance guessing mimetype of tool file (#17640)

This commit is contained in:
Qun 2025-04-10 11:14:20 +08:00 committed by GitHub
parent 6df0215246
commit 0e136b42a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -108,7 +108,11 @@ class ToolFileManager:
except httpx.TimeoutException:
raise ValueError(f"timeout when downloading file from {file_url}")
mimetype = guess_type(file_url)[0] or "application/octet-stream"
mimetype = (
guess_type(file_url)[0]
or response.headers.get("Content-Type", "").split(";")[0].strip()
or "application/octet-stream"
)
extension = guess_extension(mimetype) or ".bin"
unique_name = uuid4().hex
filename = f"{unique_name}{extension}"