Firefox忽略响应头的内容范围,只播放发送的样本 [英] Firefox ignoring response header content-range and playing only the sample sent
问题描述
我为 mp3
文件构建了一个音频流,每次客户端点击音频时,都会收到如下所示的内容:
但是它所做的只是播放1分钟样本,而不是120分钟
我在这里做错了什么? h2_lin>解决方案
不是100%确定,因为您没有提供代码或示例流来测试,但是您对HTTP范围请求的处理已被中断。
在示例请求中,客户端发送 Range:bytes = 0 -
,服务器响应1MiB响应:
Content-Length:1048576
(aka。1 MiB) code> Content-Range:0-1048575 /...
这是错误的,客户没有请求这个!它请求了 bytes = 0 -
,这意味着从位置0到整个流结束的所有数据(参见 http 1.1 RFC ),即响应等于1而不带任何 Range
。 (IIRC,Firefox仍然会发送 Range:bytes = 0 -
来检测服务器是否处理范围)。
这与 Content-Length
结合在一起,导致客户端(Firefox)认为整个资源的大小只有1MiB,而不是真正的大小。我可以想象你的测试流的前1个MiB是以音频的1:06出现的。
PS: I have built an audio stream for But what it does is just plays 1 minute sample instead of 120 minute What am I doing wrong here? Not 100% sure because you didn't provide code or an example stream to test, but your handling of HTTP range requests is broken. In your example request, the client sends This is wrong, the client did not request this! It did request This, combined with the PS: The 这篇关于Firefox忽略响应头的内容范围,只播放发送的样本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! Content-Duration
header(也就是RFC 3803)是浏览器通常不会实现的东西,只是忽略。
mp3
files, and each time client hits the audio it receives something like this:Range: bytes=0-
, and your server responds with a 1MiB response:
Content-Length: 1048576
(aka. 1 MiB)Content-Range: 0-1048575/...
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
, 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.Content-Duration
header (aka. RFC 3803) is something browsers don't usually implement at all and just ignore.