I am trying to deal with this documentation. https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests

I would not like to go to the roots of node.js. I currently specialize in front-end, so I use express.js because It is easy to learn. I want to send the audio / mpeg file to the client in pieces. As the initiating request from the client, give the Content-Length, without giving the entire file. When you just send files using res.sendFile res.download, Express.js automatically sets Content-Length. But I do not need to send the entire file.

I will be glad to answer or links to useful articles (en, ru) on the subject of partial data transfer in node.js / express.js.

    1 answer 1

    If the question is how to set a heading for the answer, then, something like this

    response.writeHead(200, { 'Content-Length': N }); // N - длина ответа в байтах 

    If the question is about how to send part of a file, then the official documentation on FileSystem from Node JS will help you.