简体   繁体   中英

Gzip between JavaScript and PHP

I've managed to gzip my response from my server to my client, but now I also want to gzip the data send from the client to the server. I'm using zlib.js as follows:

var gzip = new Zlib.Gzip(dataUint8Array);
var compressed = gzip.compress();

Where the returned compressed is a Uint8 array. How do I send the data to the server, especially, how do I decode this in PHP? I tried using gzdecode in PHP to decode the array, but that didn't work. Then I tried to convert the compressed array in JS back to a string before sending it to the server, but gzdecode could also not decode that. Any suggestions?

Perhaps this answer will help.

https://stackoverflow.com/a/8896524/3585500

Force uncompression with the Accept-Encoding: deflate header.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM