0

I am trying to create a multi threaded downloader using nodejs. Currently I am only able to download the file using a single thread. Its a simple http.get request in nodejs.

To create a multi threaded downloader I will have to send some http headers in my request which I am not able to figure out some how. I want to know what http headers should I be sending so that I am able to download a range of bytes from an offset.

var http = require('http');

var options = {
  host: 'hostname.com',
  path: '/path/to/a/large/file.zip',
  headers: {
    //Some headers which will help me download only a part of the file.
  }
};

callback = function(response) {
  response.on('data', function (chunk) {
     //write chunk to a file
  });
}

http.request(options, callback).end();
4

1 回答 1

1

You need Range header. Example is given in wiki

Range: bytes=500-999

For more detail see 14.35 Range in HTTP header Definitions

于 2013-04-19T18:04:03.737 回答