Proxyman version
Proxyman 2.5.1
macOS Version?
mac 10.15.5
I want to unzip my http Response
step1:
I use pako.js ,and put it into libs folder
step2:
i create Pako.js file put into addons folder, is to expose inflate function
// Pako.js
const pako = require('@libs/pako.js');
const inflate = (input) => {
return pako.inflate(input);
};
exports.inflate = inflate;
step3:
open scripting and enter the following code :
// Addons List: https://docs.proxyman.io/scripting/addons
const { inflate } = require("@addons/Pako.js");
function unzip( b64Data){
var strData = b64Data;
// Convert binary string to character-number array
var charData = strData.split('').map(function(x){return x.charCodeAt(0);});
// Turn number array into byte-array
var binData = new Uint8Array(charData);
// // unzip
var data = inflate(binData);
// Convert gunzipped byteArray back to ascii string:
strData = String.fromCharCode.apply(null, new Uint16Array(data));
return decodeURIComponent(strData);
}
function onResponse(context, url, request, response) {
console.log('begin');
if(response.body != null) {
var jsonString = JSON.stringify(response.body);
console.log('2222'+unzip(jsonString));
}
// Done
return response;
}
Console output:
begin
❌Error: incorrect header check
❌Error: Could not convert JSvalue to Dictionary. Please make sure the return value is a JS dictionary (Object)
can someone please tell me what went wrong ?
Proxyman version
Proxyman 2.5.1
macOS Version?
mac 10.15.5
I want to unzip my http Response
step1:
I use pako.js ,and put it into
libsfolderstep2:
i create Pako.js file put into
addonsfolder, is to exposeinflatefunctionstep3:
open scripting and enter the following code :
Console output:
begin
❌Error: incorrect header check
❌Error: Could not convert JSvalue to Dictionary. Please make sure the return value is a JS dictionary (Object)
can someone please tell me what went wrong ?