mirror of
https://github.com/kuaifan/dootask.git
synced 2026-06-11 18:02:22 +00:00
StreamedResponse 在 LaravelS/Swoole 下被 DynamicResponse 用 ob_start/ ob_get_clean 整体缓冲进 PHP 内存,约 700MB 文件会撞 memory_limit 导致 下载失败;且每次请求对整文件 md5_file 生成 ETag 开销巨大。 改为返回 BinaryFileResponse,由 LaravelS StaticResponse 走 Swoole 原生 sendfile(),OS 级零拷贝、不占 PHP 内存,可支持任意大小文件。去掉 ETag 全文件哈希改用 mtime。Swoole 环境下关闭 Range 分段(sendfile 只能整文件 发送,避免 206 头与整文件 body 错位),非 Swoole 环境保留原生 Range。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>