Firefox ignoring response header content-range and playing only the sample sent

前提是你 提交于 2019-12-01 22:18:38

问题


I have built an audio stream for mp3 files, and each time client hits the audio it receives something like this:

But what it does is just plays 1 minute sample instead of 120 minute

What am I doing wrong here?


回答1:


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 Range: bytes=0-, and your server responds with a 1MiB response:

  • Content-Length: 1048576 (aka. 1 MiB)
  • Content-Range: 0-1048575/...

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).

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: The Content-Duration header (aka. RFC 3803) is something browsers don't usually implement at all and just ignore.




回答2:


Just an idea. Did you tried some of the http 3xx header like: '308 Resume Incomplete' or '503 Service Temporarily Unavailable' plus 'retry-after:2' or '413 Request Entity Too Large' plus 'retry-after:2'



来源:https://stackoverflow.com/questions/24347901/firefox-ignoring-response-header-content-range-and-playing-only-the-sample-sent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!