Selaa lähdekoodia

空数组hpack压缩问题

MaiXinRong 3 vuotta sitten
vanhempi
commit
b72ee47c84
2 muutettua tiedostoa jossa 3 lisäystä ja 2 poistoa
  1. 1 1
      app/extend/helper.js
  2. 2 1
      app/public/js/global.js

+ 1 - 1
app/extend/helper.js

@@ -1482,7 +1482,6 @@ module.exports = {
     hpackArr(data) {
         const keyIndex = {}, key = [];
         const result = [];
-        result.push(key);
         for (const d of data) {
             const r = [];
             for (const prop in d) {
@@ -1494,6 +1493,7 @@ module.exports = {
             }
             result.push(r);
         }
+        if (result.length > 0) result.unshift(key);
         return result;
     }
 };

+ 2 - 1
app/public/js/global.js

@@ -1114,7 +1114,8 @@ function transFormToChinese(num) {
 }
 
 function hpackArrBack(data) {
-    if (data.length <= 1) throw '数据错误';
+    if (data.length === 0) return data;
+    if (data.length === 1) throw '数据错误';
     const result = [];
     //const keyIndex = {};
     // data[0].forEach((x, i) => {