[
https://issues.jboss.org/browse/WFLY-3376?page=com.atlassian.jira.plugin....
]
Stuart Douglas resolved WFLY-3376.
----------------------------------
Resolution: Rejected
I find it surprising that this works on other JAX-RS implementations, I would assume that
.encoding() sets the content-encoding and not the charset, which is how it seems to be be
working at the moment. The spec is kinda vague, but in general when talking about HTTP
charset is used to refer to the character encoding, while encoding is used to refer to the
content encoding (such as gzip etc).
You should try something like:
type("text/plain; charset=UTF-8")
Response encoding UTF-8 returns ISO-8859-1 encoded string
---------------------------------------------------------
Key: WFLY-3376
URL:
https://issues.jboss.org/browse/WFLY-3376
Project: WildFly
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: REST
Affects Versions: 8.0.0.Final
Environment: Win7, JDK8
Reporter:
bene.net
Assignee: Stuart Douglas
Attachments: output.txt, RRResourceVersion.java
I use curl to send a get request to the REST resource below.
{noformat}
curl -i -k --user xxx:xxx -H "Accept: text/plain" -X GET
"http://localhost:8080/veto_ifc/ifcv1/definitions/resource-versions/103" >
output.txt
{noformat}
The REST response should be "C3A4" in HEX instead of "E4".
I didn't find a way to achieve this. It works like this in Jersey.
Please see attached files as well.
{code:title=RRResourceVersion.java}
@GET
@Produces(MediaType.TEXT_PLAIN)
public Response getTextRepresentation(@PathParam("resource-version-id")
String resourceVersionId) {
Response response = null;
try {
String content = "ä";
byte[] utf8Arr = content.getBytes("UTF-8");
String hexString = RRResourceVersion.byteArray2Hex(utf8Arr);
LOGGER.info("hexString="+hexString);
String utf8Content = new String(utf8Arr, "UTF-8");
response =
Response.status(Response.Status.OK).entity(utf8Content).type(MediaType.TEXT_PLAIN).encoding("UTF-8").build();
} catch (Throwable t) {
LOGGER.error("Throwable caught. ", t);
response = RestService.createResponse(MediaType.TEXT_PLAIN_TYPE,
Response.Status.INTERNAL_SERVER_ERROR, RestService.throwable2String(t));
}
return response;
}
{code}
{noformat}
HTTP/1.1 200 OK
Content-Encoding: UTF-8
Connection: keep-alive
X-Powered-By: Undertow 1
Server: Wildfly 8
Content-Type: text/plain
Content-Length: 1
Date: Tue, 20 May 2014 09:31:43 GMT
ä
{noformat}
--
This message was sent by Atlassian JIRA
(v6.2.3#6260)