Allow compliance with SRV.15.2.22.1 to be controlled separately from STRICT_SERVLET_C...
authorkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 14 Jan 2010 08:59:19 +0000 (08:59 +0000)
committerkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 14 Jan 2010 08:59:19 +0000 (08:59 +0000)
and turn it on by default.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@899124 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/connector/Response.java
webapps/docs/config/systemprops.xml

index be00215..fceb410 100644 (file)
@@ -70,9 +70,21 @@ public class Response
 
     // ----------------------------------------------------------- Constructors
 
+    /**
+     * Compliance with SRV.15.2.22.1. 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.
+     */
+    private static final boolean ENFORCE_ENCODING_IN_GET_WRITER;
+
     static {
         // Ensure that URL is loaded for SM
         URL.isSchemeChar('c');
+
+        ENFORCE_ENCODING_IN_GET_WRITER = Boolean.valueOf(
+                System.getProperty("org.apache.catalina.connector.Response.ENFORCE_ENCODING_IN_GET_WRITER",
+                        "true")).booleanValue();
     }
 
     public Response() {
@@ -603,7 +615,7 @@ public class Response
             throw new IllegalStateException
                 (sm.getString("coyoteResponse.getWriter.ise"));
 
-        if (Globals.STRICT_SERVLET_COMPLIANCE) {
+        if (ENFORCE_ENCODING_IN_GET_WRITER) {
             /*
              * If the response's character encoding has not been specified as
              * described in <code>getCharacterEncoding</code> (i.e., the method
index 4656a48..7446507 100644 (file)
       dispatcher will be checked to ensure that it has wrapped the original
       request or response. (SRV.8.2 / SRV.14.2.5.1)
       </li>
-      <li>a call to <code>Response.getWriter()</code> if no character encoding
-      has been specified will result in subsequent calls to
-      <code>Response.getCharacterEncoding()</code> returning
-      <code>ISO-8859-1</code> and the <code>Content-Type</code> response header
-      will include a <code>charset=ISO-8859-1</code> component. (SRV.15.2.22.1)
-      </li>
       <li>every request that is associated with a session will cause the
       session's last accessed time to be updated regardless of whether or not
       the request explicitly accesses the session. (SRV.7.6)  
       overridden by explicitly setting the appropriate system property.</p>
     </property>
 
+    <property name="org.apache.catalina.connector. Response.ENFORCE_ENCODING_IN_GET_WRITER">
+      <p>If this is <code>true</code> then
+      a call to <code>Response.getWriter()</code> if no character encoding
+      has been specified will result in subsequent calls to
+      <code>Response.getCharacterEncoding()</code> returning
+      <code>ISO-8859-1</code> and the <code>Content-Type</code> response header
+      will include a <code>charset=ISO-8859-1</code> component. (SRV.15.2.22.1)
+      <br />
+      If not specified, the default specification compliant value of
+      <code>true</code> will be used.</p>
+    </property>
+
     <property
     name="org.apache.catalina.session. StandardSession.ACTIVITY_CHECK">
       <p>If this is <code>true</code> or if