Hi all

I have run across a problem, where the last few bytes of the entity body are not transferred to the client.

The problem occurs if the number of characters in the entity body does not match the number of bytes in the encoded string (in my case UTF-8).

Example 1:

   @GET
   @Produces("text/plain")
   public Response dsearch() {
       String result = "Romän";
       return Response.ok().entity(result).build();
   }

Here Restlet sets the the Content-Length to 5, the client receives the bytes 122 157 155 303 244 (in octal) corresponding to the string "Romä". The last character "n" got lost.

Restlet seems to set the Content-Length to the number of characters in the entity instead of to the number of bytes of the encoded string, causing the loss of trailing characters.


Example 2:

   @GET
   @Produces("text/plain")
   public Response dsearch() {
       String result = "Romän";
return Response.ok().entity(result.getBytes()).build(); // note the getBytes() call
   }

This case works fine: Restlet sets the the Content-Length to 6, the client receives the bytes 122 157 155 303 244 156 (in octal) corresponding to the full string "Romän".

Is it a bug or a feature?

Cheers,
Roman

Reply via email to