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
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@
1180261 13f79535-47bb-0310-9956-
ffa450edef68
* 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();
}
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);
}
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
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.