Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-4281

Response Encoding returned by CreationContainerListRestlet is ISO-8859-15 instead UTF-8

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 5.1.6
    • Fix Version/s: 5.1.6, 5.1.x, 5.3.1
    • Component/s: None
    • Environment:
      Restlet v1.0.7

      Description

      This code not set the response encoding :
      res.setEntity(resultDocument.asXML(), MediaType.TEXT_XML);

      by default this setEntity generate a StringRepresentation with charSet set to Null.
      And for americans, it's logic to create StringRepresentation like that :

      public StringRepresentation(CharSequence text, MediaType mediaType,
      Language language)

      { this(text, mediaType, language, CharacterSet.ISO_8859_1); }

      In com.noelios.restlet.http.HttpServerConverter.addResponseHeaders implements that :
      if (entity.getMediaType() != null) {
      StringBuilder contentType = new StringBuilder(entity
      .getMediaType().getName());

      if (entity.getCharacterSet() != null)

      { // Specify the character set parameter contentType.append("; charset=").append( entity.getCharacterSet().getName()); }

      responseHeaders.add(HttpConstants.HEADER_CONTENT_TYPE,
      contentType.toString());
      }

      So we need to create explicitly StringRepresentation and add characterSet in the representation (che) :

      Representation rep = new StringRepresentation(resultDocument.asXML(), MediaType.TEXT_XML);
      rep.setCharacterSet(CharacterSet.UTF_8);
      res.setEntity(rep);

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: