Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

184
Views
Can the server respond with content-length less than requested range if proper headers are used

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);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If you can't satisfy the requested range, you want to respond with 416, and include a Content-Range header telling the client what the satisfiable range actually is. See

https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/416

If you're really going to handle range requests yourself, you probably want to read the RFC. You need to gracefully handle badly formatted requests, unknown units, multiple ranges, etc. The page I linked above has a link to the current RFC.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!