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

后端 未结 2 523
青春惊慌失措
青春惊慌失措 2021-01-19 05:32

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

相关标签:
2条回答
  • 2021-01-19 05:48

    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'

    0 讨论(0)
  • 2021-01-19 05:53

    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.

    0 讨论(0)
提交回复
热议问题