Author: markt
Date: Fri Oct  7 22:00:06 2011
New Revision: 1180261

URL: http://svn.apache.org/viewvc?rev=1180261&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51952
Make inclusion of a response body for redirects optional as it may cause
issues and is only SHOULD in RFC2616. See also
https://issues.apache.org/bugzilla/show_bug.cgi?id=41718

Modified:
    tomcat/trunk/java/org/apache/catalina/Context.java
    tomcat/trunk/java/org/apache/catalina/connector/Response.java
    tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
    tomcat/trunk/webapps/docs/config/context.xml

Modified: tomcat/trunk/java/org/apache/catalina/Context.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/Context.java?rev=1180261&r1=1180260&r2=1180261&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/Context.java (original)
+++ tomcat/trunk/java/org/apache/catalina/Context.java Fri Oct  7 22:00:06 2011
@@ -1391,5 +1391,17 @@ public interface Context extends Contain
      * resource.
      */
     public boolean getPreemptiveAuthentication();
+
+    /**
+     * Configures if a response body is included when a redirect response is
+     * sent to the client.
+     */
+    public void setSendRedirectBody(boolean enable);
+    
+    /**
+     * Dtermines if the context is configured to included a response body as
+     * part of a redirect response.
+     */
+    public boolean getSendRedirectBody();
 }
 

Modified: tomcat/trunk/java/org/apache/catalina/connector/Response.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/Response.java?rev=1180261&r1=1180260&r2=1180261&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/Response.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/Response.java Fri Oct  7 
22:00:06 2011
@@ -1335,10 +1335,12 @@ public class Response
             String absolute = toAbsolute(location);
             setStatus(SC_FOUND);
             setHeader("Location", absolute);
-            PrintWriter writer = getWriter();
-            writer.print(sm.getString("coyoteResponse.sendRedirect.note",
-                    RequestUtil.filter(absolute)));
-            flushBuffer();
+            if (getContext().getSendRedirectBody()) {
+                PrintWriter writer = getWriter();
+                writer.print(sm.getString("coyoteResponse.sendRedirect.note",
+                        RequestUtil.filter(absolute)));
+                flushBuffer();
+            }
         } catch (IllegalArgumentException e) {
             setStatus(SC_NOT_FOUND);
         }

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardContext.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardContext.java?rev=1180261&r1=1180260&r2=1180261&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardContext.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardContext.java Fri Oct  7 
22:00:06 2011
@@ -859,7 +859,21 @@ public class StandardContext extends Con
 
     private boolean preemptiveAuthentication = false;
 
+    private boolean sendRedirectBody = false;
+
+    
     // ----------------------------------------------------- Context Properties
+    
+    @Override
+    public boolean getSendRedirectBody() {
+        return sendRedirectBody;
+    }
+
+
+    @Override
+    public void setSendRedirectBody(boolean sendRedirectBody) {
+        this.sendRedirectBody = sendRedirectBody;
+    }
 
 
     @Override

Modified: tomcat/trunk/webapps/docs/config/context.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/config/context.xml?rev=1180261&r1=1180260&r2=1180261&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/config/context.xml (original)
+++ tomcat/trunk/webapps/docs/config/context.xml Fri Oct  7 22:00:06 2011
@@ -365,6 +365,14 @@
         string, else the default value will be <code>jsp</code>.</p>
       </attribute>
 
+      <attribute name="sendRedirectBody" required="false">
+        <p>If <code>true</code>, redirect responses will include a short
+        response body that includes details of the redirect as recommended by
+        RFC 2616. This is disabled by default since including a response body
+        may cause problems for some application component such as compression
+        filters.</p>
+      </attribute>
+      
       <attribute name="sessionCookieDomain" required="false">
         <p>The domain to be used for all session cookies created for this
         context. If set, this overrides any domain set by the web application.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to