Re: 2.0snapshot Encoder.setMinimumSize broken

2009-12-18 Thread Thierry Boileau
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


Re: 2.0snapshot Encoder.setMinimumSize broken

2009-12-15 Thread weltermann17
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


-- 
View this message in context: 
http://n2.nabble.com/2-0snapshot-Encoder-setMinimumSize-broken-tp4162958p4169542.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Re: 2.0snapshot Encoder.setMinimumSize broken

2009-12-14 Thread Thierry Boileau
Hello Guido,


I've unsuccessfully tried to reproduce your issue. Could you tell us 
more about your context (connectors on server side, servlet container, 
kind of clients, etc)?

Best regards,
Thierry Boileau

> Hello,
>
> I used setMinimumSize to not gzip if everything fits into a mtu. In the
> current snapshot (not in m6) this cuts off the last two characters eg. of a
> json string when strings are short (below 400 bytes). This does not seem to
> be related to the size parameter, I tried with 100, 1000, 1 always with
> the same effect.
>
> Not calling setMinimumSize is a workaround. Is there a default other than 0?
>
> Best regards,
> Guido Schmidt.
>

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


2.0snapshot Encoder.setMinimumSize broken

2009-12-14 Thread weltermann17
Hello,

I used setMinimumSize to not gzip if everything fits into a mtu. In the
current snapshot (not in m6) this cuts off the last two characters eg. of a
json string when strings are short (below 400 bytes). This does not seem to
be related to the size parameter, I tried with 100, 1000, 1 always with
the same effect.

Not calling setMinimumSize is a workaround. Is there a default other than 0?

Best regards,
Guido Schmidt.
-- 
View this message in context: 
http://n2.nabble.com/2-0snapshot-Encoder-setMinimumSize-broken-tp4162958p4162958.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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