Преглед изворни кода

Another attempt to catch zlib decompression errors

shamoon пре 2 година
родитељ
комит
b437ccde2f
1 измењених фајлова са 5 додато и 7 уклоњено
  1. 5 7
      src/utils/proxy/http.js

+ 5 - 7
src/utils/proxy/http.js

@@ -33,15 +33,13 @@ function handleRequest(requestor, url, params) {
       const contentEncoding = response.headers['content-encoding']?.trim().toLowerCase();
       const contentEncoding = response.headers['content-encoding']?.trim().toLowerCase();
 
 
       let responseContent = response;
       let responseContent = response;
-
-      // zlib errors
-      responseContent.on("error", (e) => {
-        logger.error(e);
-        responseContent = response; // fallback
-      });
-
       if (contentEncoding === 'gzip' || contentEncoding === 'deflate') {
       if (contentEncoding === 'gzip' || contentEncoding === 'deflate') {
         responseContent = createUnzip();
         responseContent = createUnzip();
+        // zlib errors
+        responseContent.on("error", (e) => {
+          logger.error(e);
+          responseContent = response; // fallback
+        });
         response.pipe(responseContent);
         response.pipe(responseContent);
       }
       }