From a7dd6d965d076e38f1bed9f693ae31c9c9f9cb46 Mon Sep 17 00:00:00 2001 From: Ben Phelps Date: Sat, 27 Aug 2022 12:38:32 +0300 Subject: [PATCH] handle proxying binary data --- src/utils/http.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/utils/http.js b/src/utils/http.js index eb0dfed97..8d37a2b3d 100644 --- a/src/utils/http.js +++ b/src/utils/http.js @@ -4,14 +4,14 @@ import http from "http"; export function httpsRequest(url, params) { return new Promise(function (resolve, reject) { var request = https.request(url, params, function (response) { - let data = ""; + var data = []; response.on("data", (chunk) => { - data = data + chunk.toString(); + data.push(chunk); }); response.on("end", () => { - resolve([response.statusCode, response.headers["content-type"], data]); + resolve([response.statusCode, response.headers["content-type"], Buffer.concat(data)]); }); }); @@ -26,14 +26,14 @@ export function httpsRequest(url, params) { export function httpRequest(url, params) { return new Promise(function (resolve, reject) { var request = http.request(url, params, function (response) { - let data = ""; + var data = []; response.on("data", (chunk) => { - data = data + chunk.toString(); + data.push(chunk); }); response.on("end", () => { - resolve([response.statusCode, response.headers["content-type"], data]); + resolve([response.statusCode, response.headers["content-type"], Buffer.concat(data)]); }); });