From f30f11ce2d71cf14808187838b80cdcb511e9bfb Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Sun, 11 Dec 2022 15:38:51 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D0=B8=20FileDownloader?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/core/FileDownloader.js | 7 +++++-- server/core/Reader/ReaderWorker.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/server/core/FileDownloader.js b/server/core/FileDownloader.js index 5f86e5ab..6fa06111 100644 --- a/server/core/FileDownloader.js +++ b/server/core/FileDownloader.js @@ -9,11 +9,12 @@ class FileDownloader { this.limitDownloadSize = limitDownloadSize; } - async load(url, callback, abort) { + async load(url, opts, callback, abort) { let errMes = ''; - const options = { + let options = { headers: { + 'accept-encoding': 'gzip, compress, deflate', 'user-agent': userAgent, timeout: 300*1000, }, @@ -22,6 +23,8 @@ class FileDownloader { }), responseType: 'stream', }; + if (opts) + options = Object.assign({}, opts, options); try { const res = await axios.get(url, options); diff --git a/server/core/Reader/ReaderWorker.js b/server/core/Reader/ReaderWorker.js index 6c81b40f..3a8c1c0f 100644 --- a/server/core/Reader/ReaderWorker.js +++ b/server/core/Reader/ReaderWorker.js @@ -109,7 +109,7 @@ class ReaderWorker { let downloadSize = -1; //download or use uploaded if (url.indexOf('disk://') != 0) {//download - const downdata = await this.down.load(url, (progress) => { + const downdata = await this.down.load(url, {}, (progress) => { wState.set({progress}); }, q.abort);