Hello Guido,

I've set up a sample app (served by the jetty connector) where an 
instance of a JsonRepresentation is instantiated with a string (456 
characters).
I've got also a GWT client app served by a Directory Restlet which calls 
the target resource, and in both cases there is no missing characters.

Did you try with the current snapshot? Did you try to simply send a 
StringRepresentation instead of a JsonRepresentation?


Best regards,
Thierry Boileau


> Hello,
>
> sorry for being so unspecific. I use a SE component with Jetty, the client
> is using the GWT edition. I tested with current versions of FF, Safari and
> Chrome. If the issue occurs they all show one or two characters missing at
> the end of a json string.
>
> Maybe with this small test case it becomes reproducable:
>
> public class Encoder extends org.restlet.engine.application.Encoder {
>
>       public Encoder(final Context context) {
>               super(context);
>               setMinimumSize(400);
>       }
>
>       @Override
>       public void afterHandle(final Request request, final Response response) 
> {
>               if (response.isEntityAvailable()) {
>                       final Representation entity = response.getEntity();
>                       try {
>                               System.out.println("entity : " + 
> entity.getText());
>                       } catch (final IOException e) {
>                       }
>                       System.out.println("entity size : " + entity.getSize());
>               }
>               super.afterHandle(request, response);
>       }
>
> }
>
> I test with a json rep that has a size of 317. The JsonRepresentation is
> created from a String that is built from an LDAP response or is taken out of
> a self-implemented cache directly.
>
> On the console I see
>
> entity :
> {"response":{"status":0,"startrow":0,"totalRows":1,"endrow":1,"data":[{"id":
> ...  }]}}
> entity size : 317
>
> The string is a valid json.
>
> In a SF client the web inspector reports:
> Accept-Ranges:bytes
> Cache-Control:max-age=3600
> Content-Length:317
> Content-Type:application/json; charset=UTF-8
> Date:Tue, 15 Dec 2009 11:47:34 GMT
> Expires:Tue, 15 Dec 2009 12:47:34 GMT
> Server:Restlet-Framework/2.0snapshot
> Vary:Accept-Charset, Accept-Encoding, Accept-Language, Accept
>
> But the content ends with ] the final }} are missing. Hence, I receive
> invalid data.
> Firebug on FF 355 reports the same.
>
> Changing the test code to setMinimalSize(300) I get the same correct console
> output and the web inspector reports:
> Accept-Ranges:bytes
> Cache-Control:max-age=3600
> Content-Encoding:gzip
> Content-Type:application/json; charset=UTF-8
> Date:Tue, 15 Dec 2009 11:53:01 GMT
> Expires:Tue, 15 Dec 2009 12:53:01 GMT
> Server:Restlet-Framework/2.0snapshot
> Transfer-Encoding:Identity
> Vary:Accept-Charset, Accept-Encoding, Accept-Language, Accept
>
> The content is correct. It seems that piping a json rep through the encoder
> without encoding may corrupt it.
>
> Best regards,
> Guido Schmidt
>
>
>

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

Reply via email to