问题
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