fix(files): update Content-Length handling for tool and remote files (#9649)

pull/9651/head
-LAN- 1 year ago committed by GitHub
parent 36f66d40e5
commit d6e8290a1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -42,10 +42,10 @@ class ToolFilePreviewApi(Resource):
stream,
mimetype=tool_file.mimetype,
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"]:
response.headers["Content-Disposition"] = f"attachment; filename={tool_file.name}"

@ -46,7 +46,7 @@ class RemoteFileInfoApi(WebApiResource):
response = ssrf_proxy.head(decoded_url)
return {
"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:
return {"error": str(e)}, 400

Loading…
Cancel
Save