On the client side, I use the zlib.js library to deflate some string, then I encode it into base64 to be sent to the server:
var a = {"foo" : "bar"};
var deflate = new Zlib.Deflate(JSON.stringify(a));
var compressed = deflate.compress();
var sentToServer = btoa(String.fromCharCode.apply(null, compressed));
>>> "eJwVwwEJAAAAgKD/ry3B5QAdegQ0"
On the server side I want to use zlib for python27 to decompress, but I got the following error:
import base64, zlib
a = base64.b4decode("eJwVwwEJAAAAgKD/ry3B5QAdegQ0")
zlib.decompress(a)
>>>zlib.error: Error -3 while decompressing data: invalid distance too far back
What is the proper way to achieve that?