Compressing text for HTTP with POST parameters

纵饮孤独 提交于 2019-12-10 18:46:21

问题


I am writing client software that initiates a HTTP request with a large blob of text (JSON object actually) as POST parameter. I want to compress this text before sending and decompress the text on the server.

Gzip produces binary, which I can't send as a POST parameter, I think.

Which options/algorithms exist to compress text and send it to a web server?

Edit: Would it be an option to GZIP and then BASE64 encode the binary data?


回答1:


Why don't you just use the standard HTTP gzip compression?

(It just seems a bit mad to needlessly re-invent the wheel.)

Update

Ah yes - my bad. So why not simply gzip the file, upload it to the server as you would a multipart/form-data file upload and then un-gzip it on the server?




回答2:


The file is a long/unnecessary work around, the original question relates to battle with unbearably large Json blob. From my hacking around I can tell it highly depends on the server, some do support it some don't.

To the original question, you can set the binary data in http post, the real question what is the server going to do with it. It is the same way that C# client does not automatically unzip, you have to write extra code.



来源:https://stackoverflow.com/questions/4427353/compressing-text-for-http-with-post-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!