Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-1092

Text responses should default to charset UTF-8

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 3.0.8.Final
    • Fix Version/s: 3.0.9.Final
    • Component/s: jaxrs
    • Labels:
      None
    • Workaround Description:
      Hide

      No workaround known

      Show
      No workaround known

      Description

      I use curl to send a get request to the REST resource below.

      curl -i -k --user xxx:xxx -H "Accept: text/plain" -X GET "http://localhost:8080/veto_ifc/ifcv1/definitions/resource-versions/103" > output.txt
      

      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.

      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;
          }
      
      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
      
      ä
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  ron_sigal Ronald Sigal
                  Reporter:
                  bene.net bene.net
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: