From cbdf0f7bcfc56ec3165bbfb04ed1d93df26cf683 Mon Sep 17 00:00:00 2001 From: ProtocolNebula Date: Mon, 14 Jan 2019 13:17:29 +0100 Subject: [PATCH] Fix that let download the file even if server not accept range and FILE END is different of real file size --- lib/FastDownload.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/FastDownload.js b/lib/FastDownload.js index 0971709..d8fe9d3 100755 --- a/lib/FastDownload.js +++ b/lib/FastDownload.js @@ -108,17 +108,17 @@ FastDownload.prototype._init_http = function (cb) { self._options.chunkSize = Math.ceil(self.size / self._options.chunksAtOnce) } var acceptRanges = self.headers['accept-ranges'] === 'bytes' - if ( - !acceptRanges && - (self._options.start !== 0 || self._options.end !== self.file_size) - ) { - cb(new Error('the server will not accept range requests')) - return - } - if (acceptRanges) { - self._init_fast_http(cb) - } else { + if (!acceptRanges) { + if (self._options.end.toString() != self.file_size.toString()) { + cb (new Error('the server will not accept range requests, so cannot change "end" of file')) + } + + if (self._options.start !== 0) { + self._options.start = 0 + } self._init_normal_http(cb) + } else { + self._init_fast_http(cb) } } FastDownload.prototype._init_normal_http = function (cb) {