Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

186
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda