I am creating a music web app that streams MP3s that I have stored in MongoDB(GridFS).
My Question: How can I add http range support so that I can start streaming the au
The client will send a Range
header specifying the absolute starting and ending bytes followed by total file length or '*'.
. The first 500 bytes:
bytes 0-499/1234
. The second 500 bytes:
bytes 500-999/1234
. All except for the first 500 bytes:
bytes 500-1233/1234
. The last 500 bytes:
bytes 734-1233/1234
The server should then return a response code 206
(Partial content) and the Content-Length
should be only the amount of data transmitted.
In the case the range is wrong, the server should either return 416
(Requested range not satisfiable) with a Content-Range
field of bytes */*
or should ignore the range request and return a 200
with the entire body of the file.
The server must also send an Accept-Ranges
field with the value of the accepted range unit, in this case bytes
. But the range unit can be any custom range unit you want.
Source: rfc2616