| stream, | stream, | ||||
| mimetype=tool_file.mimetype, | mimetype=tool_file.mimetype, | ||||
| direct_passthrough=True, | direct_passthrough=True, | ||||
| headers={ | |||||
| "Content-Length": str(tool_file.size), | |||||
| }, | |||||
| headers={}, | |||||
| ) | ) | ||||
| if tool_file.size > 0: | |||||
| response.headers["Content-Length"] = str(tool_file.size) | |||||
| if args["as_attachment"]: | if args["as_attachment"]: | ||||
| response.headers["Content-Disposition"] = f"attachment; filename={tool_file.name}" | response.headers["Content-Disposition"] = f"attachment; filename={tool_file.name}" | ||||
| response = ssrf_proxy.head(decoded_url) | response = ssrf_proxy.head(decoded_url) | ||||
| return { | return { | ||||
| "file_type": response.headers.get("Content-Type", "application/octet-stream"), | "file_type": response.headers.get("Content-Type", "application/octet-stream"), | ||||
| "file_length": int(response.headers.get("Content-Length", 0)), | |||||
| "file_length": int(response.headers.get("Content-Length", -1)), | |||||
| } | } | ||||
| except Exception as e: | except Exception as e: | ||||
| return {"error": str(e)}, 400 | return {"error": str(e)}, 400 |