discuz论坛程序支持附件多线程下载办法,Range请求不支持响应206状态码修复
discuz论坛程序支持附件多线程下载办法,Range请求不支持响应206状态码修复问题原文
附件下载对Range请求不支持响应206状态码吗?不能断点续传
请求头部附加
Range: bytes=0-
服务器不响应206
还是说这是我web环境问题?
感觉也不是,因为附件下载是PHP输出的,测试直接把7z文件放服务器上不经过php,静态直链输出是支持响应206的
HTTP协议如下:
The If-Range HTTP request header makes a range request conditional: if the condition is fulfilled, the range request will be issued and the server sends back a 206 Partial Content answer with the appropriate body. If the condition is not fulfilled, the full resource is sent back, with a 200 OK status.
This header can be used either with a Last-Modified validator, or with an ETag, but not with both.
The most common use case is to resume a download, to guarantee that the stored resource has not been modified since the last fragment has been received.
参考:https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Range
在单个请求中,Range头信息能够询问多个范围,这种特性称为"多部分范围(multipart ranges)"
解决办法
改config_global.php配置文件
搜索
$_config['download']['readmod'] = 2;
修改为4实测可行,已经支持Range 206成功,下载过程模式4额外内存占用对比模式2多了10M,完全可以接受
$_config['download']['readmod'] = 4;
关联:https://gitee.com/Discuz/DiscuzX/issues/I4H4VB
比如disucz的四种读取文件模式,默认值是2
// 附件下载相关
//
// 本地文件读取模式; 模式2为最节省内存方式,但不支持多线程下载
// 如需附件URL地址、媒体附件播放,需选择支持Range参数的读取模式4,其他模式会导致部分浏览器下视频播放异常
// 1=fread 2=readfile 3=fpassthru 4=fpassthru+multiple
$_config['download']['readmod'] = 2;
不懂标记路过{:3028:}{:3041:}
页:
[1]