Sending restlet response in zip format

匆匆过客 提交于 2019-12-11 01:26:22

问题


I am trying to send my restlet response in zip format if it i slarger then a specific size. This is the link i got that help enabling the encoding service. But i still dont get the response in zip format.

How can I enable GZIP compression of the JSON response entity on Reslet?

Do i need to send something in the request header or make some other changes to get the response in zip format. Currently my restlet returns an object of a local class that is received at client side in json format.


回答1:


the Encoder filter transparently compresses the body of the response in order to reduce the size of the HTTP payload. If your client automatically uncompresses the response's body, you will have the feeling that nothing happens. What kind of client are you using? Do you have a "content-encoding" header in the response?

If you would like your client to really receive a zip response in order to store it, for example, you can wrap the core representation manually on server side:

new org.restlet.engine.application.EncodeRepresentation(org.restlet.data.Encoding.ZIP, representation);


来源:https://stackoverflow.com/questions/23627276/sending-restlet-response-in-zip-format

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