*Emailing it again as earlier it was not properly formatted. Sorry.*

Hi Sergey,

I was going through this thread since I want to enable GZIP on encoding
server side.

I have successfully configured GZIP encoding by adding cxf:feature in cxf's
xml. I have also added @GZIP annotation to the resource file. Below is the
set of annotations over resource file:

@GZIP
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML,
MediaType.APPLICATION_FORM_URLENCODED })

I have a few doubts. Hope you can help me understand them. I am using
fiddler to send the request.

1. When I am sending request with below header:

> If it sends:
> Accept-Encoding: gzip,deflate
> Accept: */*

Response generated is in JSON format but it is not GZIP encoded. In this
case Content-Encoding is not set to GZIP.

2. When I am sending request with below header:

Accept-Encoding: gzip,deflate
Accept: application/xml

Response generated is in XML format and its GZIP encoded. In this case
Content-Encoding is set to GZIP.

Does GZIP encoding is not supported in case response returned is in JSON
format??

Thanks for any pointers.

PG.

On Tue, Sep 23, 2014 at 10:46 AM, pg <[email protected]> wrote:

> Hi Sergey, I was going through this thread since I want to enable GZIP on
> encoding server side.I have successfully configured GZIP encoding by adding
> cxf:feature in cxf's xml. I have also added @GZIP annotation to the
> resource
> file. Below is the set of annotations over resource file:@GZIP@Produces({
> MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })@Consumes({
> MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML,
> MediaType.APPLICATION_FORM_URLENCODED })I have a few doubts. Hope you can
> help me understand them. I am using fiddler to send the request.1. When I
> am
> sending request with below header:> If it sends: > Accept-Encoding:
> gzip,deflate > Accept: */* Response generated is in JSON format but it is
> GZIP encoded. In this case Content-Encoding is not set to GZIP.2. When I am
> sending request with below header:Accept-Encoding: gzip,deflate Accept:
> application/xmlResponse generated is in XML format and its GZIP encoded. In
> this case Content-Encoding is set to GZIP.Does GZIP encoding is not
> supported in case response returned is in JSON format??Thanks for any
> pointers.PG.
> Sergey Beryozkin wrote
> > Hi AnthonyOn 05/10/12 11:11, Muller, Anthony wrote:> Hello Sergey,>> I
> > feel I miss something about GZIP support.>> I added @GZIP to our root
> > resource.>> So, in my usecase that I have a method in my RESTful ws that
> > returned a JAXB object (so, the method can produce "application/xml" and
> > "application/json").>> How the client can ask a XML or JSON in GZIP
> > format?>> If it sends:>       Accept-Encoding: gzip,deflate>  Accept:
> */*> It
> > works.>> But if client sends:>        Accept-Encoding: gzip,deflate>
> Accept:
> > application/json> I received a "406 Not Accepted"...Does it work if drop
> > @GZIP ? I wonder if you have @Produces that also allows for
> > application/json ?Cheers, Sergey>> How to do?>> Regards,> Anthony>>>>>
> > -----Original Message-----> From: Sergey Beryozkin [mailto:
>
> > sberyozkin@
>
> > ]> Sent: jeudi 20 septembre 2012 13:40> To: Muller, Anthony> Cc:
>
> > [email protected]
>
> >> Subject: Re: JAX-RS - ZIP compression ?>> Hi> On 20/09/12 12:23, Muller,
> >> Anthony wrote:>> ->   If GZIP is acceptable then the simples option is
> to
> >> add>> ->   @org.apache.cxf.annotation.GZIP to a root resource class.>>>>
> >> Just to be sure, in this case, after adding this annotation:>> - all
> >> subresources class will be configured as well or I have to add this
> >> annotation too?>> Having it at a root resource class level should do,>>
> >> Alternatively, register>
> >> org.apache.cxf.transport.common.gzip.GZIPFeature. Actually, it is not>
> >> possible to register features with CXFNonSpingJaxrsServlet, so the same>
> >> can be achieved by registering>
> >> org.apache.cxf.transport.common.gzip.GZIPOutInterceptor (via>
> >> jaxrs.outInterceptors parameter) and if needed ->
> >> org.apache.cxf.transport.common.gzip.GZIPInInterceptor>>> - must I add a
> >> "application/x-gzip" MIME type on JAX-RS methods?>>> it depends on what
> >> the client expectations are, if clients do expect> "application/x-gzip"
> >> then you can add it to a root resource class level...>>
> >> GZIPOutInterceptor will only set 'Content-Encoding' to "gzip" or
> >> "x-gzip">> Cheers, Sergey>>> Regards,>> Anthony>>>> -----Original
> >> Message----->> From: Muller, Anthony [mailto:
>
> > anthony.muller@
>
> > ]>> Sent: jeudi 20 septembre 2012 13:09>> To: Sergey Beryozkin;
>
> > [email protected]
>
> >>> Subject: RE: JAX-RS - ZIP compression ?>>>> Thanks Sergey, I will look
> >>> at this asap :)>>>> Regards,>> Anthony>>>> PS: about this point, we
> >>> choose to have an interceptor mechanism at application level to handle
> >>> lock/unlock on resources when necessary. Thanks!>>>> -----Original
> >>> Message----->> From: Sergey Beryozkin [mailto:
>
> > sberyozkin@
>
> > ]>> Sent: mardi 18 septembre 2012 22:57>> To:
>
> > [email protected]
>
> >>> Cc: Muller, Anthony>> Subject: Re: JAX-RS - ZIP compression ?>>>> Hi
> >>> Anthony>> On 18/09/12 21:36, Muller, Anthony wrote:>>> Hello
> >>> Sergey,>>>>>> Is there an (easy) way to accept/activate ZIP compression
> >>> of REST responses?>>>>> If GZIP is acceptable then the simples option
> is
> >>> to add>> @org.apache.cxf.annotation.GZIP to a root resource class.>>>>
> >>> We also have a utility for supporting Deflate [1] encoding which I
> >>> guess>> is somewhat different to GZIP:>>>>
> >>> http://docs.oracle.com/javase/7/docs/api/java/util/zip/Deflater.html
> >>>>
> >>> The actual utility is in the rs xml security module - but if it were
> >>> of>> interest then we'd make it available at the common rt/core level,
> >>> let us>> know...>>>> Cheers, Sergey>>>>> Thanks,>>> Anthony>>>>>>> P.S
> >>> By the way, recall our conversation about making sure that a custom>>
> >>> ResponseHandler is invoked even if the exception is thrown from the>>
> >>> server application code, I can't seem to find that thread, but the
> >>> thing>> which I forgot to mention last time was that providing a
> >>> custom>> ExceptionMapper for Throwable would guarantee a Response would
> >>> be avail>> for response filters no matter what>>
>
>
>
>
>
> --
> View this message in context:
> http://cxf.547215.n5.nabble.com/JAX-RS-ZIP-compression-tp5714099p5749070.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>

Reply via email to