Hi Boris, You should try to enable and configure the "encoderService" property on your JaxRsApplication (subclass of Application). See org.restlet.service.EncoderService class as well.
Best regards, Jerome -- http://www.restlet.com http://twitter.com/#!/jlouvel -----Message d'origine----- De : Borislav Iordanov [mailto:bo...@miamidade.gov] Envoyé : mardi 17 avril 2012 21:45 À : discuss@restlet.tigris.org Objet : JAX-RS and gzip Hi guys, Any idea how to compress large JSON content using the JAX-RS implementation in Restlet? I have a MessageBodyWriter that writes Json objects to the output stream. It is annotated with: @javax.ws.rs.Produces("application/json") and it works fine. But I'd like to be able to compress the content with gzip which is automatically recognized by browsers given the appropriate HTTP response headers. To achieve that I tried the following: public void writeTo(Json t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { httpHeaders.put("Content-Type", Collections.singletonList((Object)"application/json")); httpHeaders.put("Content-Encoding", Collections.singletonList((Object)"gzip")); java.util.zip.GZIPOutputStream gzip = new java.util.zip.GZIPOutputStream(entityStream); gzip.write(t.toString().getBytes()); } But I'm getting an exception: "The changing of the http headers is not supported by this runtime environment." What would be the suggested way? Thanks much! Boris ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=29492 29 ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2949449