I've gotta say I've had a good time getting to know restlet and have found it
to be incredibly useful, however, I'm really wracking my brain tonight on
this one (please excuse the poor code, I'm tired and can't be bothered  :)
)...

Firstly, it seems that the client by default doesn't accept a GZIP
representation (I thought this was on by default). So, in order to get the
server to send one I have to do the following:

    ClientInfo clientInfo = clientResource.getClientInfo();
    List<Preference&lt;Encoding>> preflist =
clientInfo.getAcceptedEncodings();
    preflist.add(new Preference<Encoding>(Encoding.GZIP));


If I try to do a seamless wrapping of the JSON representation using the
jackson library I use the following code:

    SomeResource sr =
clientResource.getChild("/someresource/",SomeResource.class);

This results in "org.codehaus.jackson.JsonParseException: Illegal character
((CTRL-CHAR, code 31)): only regular white space (\r, \n, \t) is allowed
between tokens"
(I assume this means that the GZIP representation is not being decoded on
the fly)

If I manually get the resource and use the DecodeRepresentation like thus, I
get the JSON representation as it should look:

    ClientResource cr = clientResource.getChild("/someresource/");
    Representation r = cr.get();
    Representation r2 = new DecodeRepresentation(r);
    System.out.println("REPRESENTATION : " + r2.getText());


-------
Now, I noticed that the DecoderService is meant to be working on the Client
by default (btw, I'm using Restlet 2.1 RC1) however it stems from Restlet
Application - maybe a dumb question but how do I access the decoderservice
from the client or should it just _work_?? Really feel in the dark here and
it's hard to know if I'm losing it or if there is indeed a bug?

Thanks guys!!

--
Sean

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/client-side-gzip-decoding-tp6884740p6921927.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2861652

Reply via email to