简体   繁体   English

JavaScript和PHP之间的Gzip

[英]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. 我已经设法将我的响应从服务器gzip压缩到客户端,但是现在我还想将从客户端发送的数据gzip压缩到服务器。 I'm using zlib.js as follows: 我正在使用zlib.js ,如下所示:

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

Where the returned compressed is a Uint8 array. 返回的压缩文件是Uint8数组。 How do I send the data to the server, especially, how do I decode this in PHP? 如何将数据发送到服务器,特别是如何在PHP中解码数据? I tried using gzdecode in PHP to decode the array, but that didn't work. 我尝试在PHP中使用gzdecode解码数组,但这没有用。 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. 然后,我尝试将JS中的压缩数组转换回字符串,然后再将其发送到服务器,但是gzdecode也无法对其进行解码。 Any suggestions? 有什么建议么?

Perhaps this answer will help. 也许这个答案会有所帮助。

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

Force uncompression with the Accept-Encoding: deflate header. 使用Accept-Encoding:deflate标头强制解压缩。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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