Grails
  1. Grails
  2. GRAILS-8131

XML converter should pass contentType AND charset in the render method to the response object

    Details

    • Type: Improvement Improvement
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0-M2
    • Fix Version/s: None
    • Component/s: Converters
    • Labels:
      None
    • Environment:
      ubuntu 64bit java6 tomcat6 tomcat7

      Description

      The XML converter is passing the contentType to the response object like this:

      public void render(HttpServletResponse response) throws ConverterException {
              response.setContentType("text/xml");
      

      I think it should also add the charset encoding that it gets from the configuration (defaults to UTF-8):

      public void render(HttpServletResponse response) throws ConverterException {
              response.setContentType("text/xml;charset=" + encoding);
      

      This would ease development and deployment. As Grails 2.0 uses internally a Tomcat7, but deployments often happen on Tomcat6. AFAIK By passing the already present encoding, no reconfiguration of Tomcat would be necessary.

      From http://tomcat.apache.org/tomcat-6.0-doc/config/systemprops.html

      org.apache.catalina.STRICT_SERVLET_COMPLIANCE
      [...]
      a call to Response.getWriter() if no character encoding has been specified will result in subsequent calls to Response.getCharacterEncoding() returning ISO-8859-1 and the Content-Type response header will include a charset=ISO-8859-1 component. (SRV.15.2.22.1)
      [...]
      If not specified, the default value of false will be used.

      This changed to a new system property in tomcat 7
      From http://tomcat.apache.org/tomcat-7.0-doc/config/systemprops.html

      org.apache.catalina.connector.Response.ENFORCE_ENCODING_IN_GET_WRITER

      If this is true then a call to Response.getWriter() if no character encoding has been specified will result in subsequent calls to Response.getCharacterEncoding() returning ISO-8859-1 and the Content-Type response header will include a charset=ISO-8859-1 component. (SRV.15.2.22.1)

      If not specified, the default specification compliant value of true will be used.

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            PhilippJ
          • Votes:
            3 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Last Reviewed:

              Development