"org.apache.coyote.USE_CUSTOM_STATUS_MSG_IN_HEADER",
"false")).booleanValue();
+ /**
+ * Limit on the total length of the trailer headers in
+ * a chunked HTTP request.
+ */
+ public static final int MAX_TRAILER_SIZE =
+ Integer.parseInt(System.getProperty(
+ "org.apache.coyote.MAX_TRAILER_SIZE",
+ "8192"));
}
client.processRequest();
assertEquals("null7TestTestTest0123456789abcdefghijABCDEFGHIJopqrstuvwxyz", client.getResponseBody());
}
-
+
+ public void testTrailingHeadersSizeLimit() throws Exception {
+ // Setup Tomcat instance
+ Tomcat tomcat = getTomcatInstance();
+
+ // Must have a real docBase - just use temp
+ Context ctx =
+ tomcat.addContext("", System.getProperty("java.io.tmpdir"));
+
+ Tomcat.addServlet(ctx, "servlet", new EchoHeaderServlet());
+ ctx.addServletMapping("/", "servlet");
+
+ tomcat.start();
+
+ StringBuilder longText = new StringBuilder("Test1234567890");
+ while (longText.length() <= 8192) {
+ longText.append(longText.toString());
+ }
+
+ String[] request = new String[]{
+ "POST /echo-params.jsp HTTP/1.1" + SimpleHttpClient.CRLF +
+ "Host: any" + SimpleHttpClient.CRLF +
+ "Transfer-encoding: chunked" + SimpleHttpClient.CRLF +
+ "Content-Type: application/x-www-form-urlencoded" +
+ SimpleHttpClient.CRLF +
+ "Connection: close" + SimpleHttpClient.CRLF +
+ SimpleHttpClient.CRLF +
+ "3" + SimpleHttpClient.CRLF +
+ "a=0" + SimpleHttpClient.CRLF +
+ "4" + SimpleHttpClient.CRLF +
+ "&b=1" + SimpleHttpClient.CRLF +
+ "0" + SimpleHttpClient.CRLF +
+ "x-trailer: Test" + longText + SimpleHttpClient.CRLF +
+ SimpleHttpClient.CRLF };
+
+ TrailerClient client = new TrailerClient();
+ client.setPort(getPort());
+ client.setRequest(request);
+
+ client.connect();
+ client.processRequest();
+ // Expected to fail because the trailers are longer
+ // than the default limit of 8Kb
+ assertTrue(client.isResponse500());
+ }
+
public void testNoTrailingHeaders() throws Exception {
// Setup Tomcat instance
Tomcat tomcat = getTomcatInstance();
<p>If not specified, the default value of <code>false</code> will be used.</p>
</property>
+ <property name="org.apache.coyote.MAX_TRAILER_SIZE">
+ <p>Limits the total length of trailing headers in the last chunk of
+ a chunked HTTP request.
+ If the value is <code>-1</code>, no limit will be imposed.</p>
+ <p>If not specified, the default value of <code>8192</code> will be used.</p>
+ </property>
+
<property name="catalina.useNaming">
<p>If this is <code>false</code> it will override the
<code>useNaming</code> attribute for all <a href="context.html">