[jboss-jira] [JBoss JIRA] (WFLY-3376) Response encoding UTF-8 returns ISO-8859-1 encoded string

Stuart Douglas (JIRA) issues at jboss.org
Tue May 20 13:18:56 EDT 2014


     [ https://issues.jboss.org/browse/WFLY-3376?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stuart Douglas reopened WFLY-3376:
----------------------------------



> 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: 3.0.7.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)



More information about the jboss-jira mailing list