Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

185
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda