Hi Roman,
when I have a look at the source code of the StringRepresentation class,
I notice that the length is computed on via the "getBytes" method which
should calcute the correct length.
I have a few questions: as I think that this code
("Response.ok().entity(result).build();") is certainly base on some of
your own classes, we would like to know what kind of Representation are
you using? Is it possible for you to update the character set of the
returned representation and test with several charsets?
Best regards,
Thierry Boileau
--
Restlet ~ Core developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com
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