I am developing a Node-JS server with some custom behavior for video streaming.
Server is exposing a file as stream on the root path localhost:3000/
and listens for range requests. On the frontend there is a html5 video player which I have noticed by logging, request from in range values current-byte to total-bytes
when you scrub on the timeline.
For now I am just piping the file-stream into the response.
My scenario requires me to query another process about the file in question and only pipe down the part of file that it allows me to. Now my question is if the player requests for example from byte 0 to 1000 and I respond with 0 to 100 and I set the headers like below, would the player understand that it didnt get the full data it wanted and make any subsequent requests.
const range = fromOtherProcess(); // the other process told me this range is allowed
response.statusCode = 206; // parital content
response.setHeader('Content-Length', range.end - range.start + 1);
response.setHeader('Content-Range', 'bytes ' + range.start + '-' + range.end + '/' + size);