Firefox 忽略响应标头内容范围并仅播放发送的示例 [英] Firefox ignoring response header content-range and playing only the sample sent
问题描述
我为 mp3
文件构建了一个音频流,每次客户端点击音频时,它都会收到如下内容:
I have built an audio stream for mp3
files, and each time client hits the audio it receives something like this:
但它所做的只是播放 1 分钟的样本而不是 120 分钟
But what it does is just plays 1 minute sample instead of 120 minute
我在这里做错了什么?
推荐答案
不是 100% 确定,因为您没有提供代码或示例流进行测试,但是您对 HTTP 范围请求的处理被破坏了.
Not 100% sure because you didn't provide code or an example stream to test, but your handling of HTTP range requests is broken.
在您的示例请求中,客户端发送 Range: bytes=0-
,您的服务器以 1MiB 响应:
In your example request, the client sends Range: bytes=0-
, and your server responds with a 1MiB response:
内容长度:1048576
(又名 1 MiB)内容范围:0-1048575/...
Content-Length: 1048576
(aka. 1 MiB)Content-Range: 0-1048575/...
这是错误的,客户端没有要求这个!它确实请求了 bytes=0-
,这意味着从位置 0 到整个流末尾的所有数据(参见 http 1.1 RFC),即一个等于 1 的响应,没有任何 Range
.(IIRC,Firefox 仍然发送 Range: bytes=0-
来检测服务器是否首先处理范围).
This is wrong, the client did not request this! It did request bytes=0-
, meaning all data from position 0 to the end of the entire stream (See the http 1.1 RFC), i.e. a response equal to one without any Range
. (IIRC, Firefox still sends the Range: bytes=0-
to detect if the Server handles ranges in the first place).
这与 Content-Length
相结合,导致客户端 (Firefox) 认为整个资源的大小仅为 1MiB,而不是实际大小.我想您的测试流的前 1 MiB 会以 1:06 的音频出现.
This, combined with the Content-Length
, leads the client (Firefox) to think the whole resource is just 1MiB in size, instead of the real size. I'd imagine the first 1 MiB of your test stream comes out as 1:06 of audio.
PS:Content-Duration
标头(又名 RFC 3803)是浏览器通常根本不实现而只是忽略的东西.
PS: The Content-Duration
header (aka. RFC 3803) is something browsers don't usually implement at all and just ignore.
这篇关于Firefox 忽略响应标头内容范围并仅播放发送的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!