You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2022/04/11 11:19:34 UTC

[tomcat] branch 8.5.x updated: PR501: Add header size attributes

This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/8.5.x by this push:
     new 5567e2e30e PR501: Add header size attributes
5567e2e30e is described below

commit 5567e2e30e8a2ec40a084274edcabb045a18246f
Author: remm <re...@apache.org>
AuthorDate: Mon Apr 11 13:14:17 2022 +0200

    PR501: Add header size attributes
    
    Add new maxHttpRequestHeaderSize and maxHttpResponseHeaderSize
    attributes which allow setting the maximum HTTP header sizes
    independently. If not specified, the value of the maxHttpHeaderSize
    connector attribute will be used.
    Added documentation.
    Submitted by Zhongming Hua.
---
 .../coyote/http11/AbstractHttp11Protocol.java      | 28 ++++++++++++++++++++++
 java/org/apache/coyote/http11/Http11Processor.java |  4 ++--
 webapps/docs/changelog.xml                         | 11 +++++++++
 webapps/docs/config/http.xml                       | 12 ++++++++++
 4 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/http11/AbstractHttp11Protocol.java b/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
index 8c5b3f49d0..4d706ba53d 100644
--- a/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
+++ b/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
@@ -273,6 +273,34 @@ public abstract class AbstractHttp11Protocol<S> extends AbstractProtocol<S> {
     public void setMaxHttpHeaderSize(int valueI) { maxHttpHeaderSize = valueI; }
 
 
+    /**
+     * Maximum size of the HTTP request message header.
+     */
+    private int maxHttpRequestHeaderSize = -1;
+
+    public int getMaxHttpRequestHeaderSize() {
+        return maxHttpRequestHeaderSize == -1 ? getMaxHttpHeaderSize() : maxHttpRequestHeaderSize;
+    }
+
+    public void setMaxHttpRequestHeaderSize(int valueI) {
+        maxHttpRequestHeaderSize = valueI;
+    }
+
+
+    /**
+     * Maximum size of the HTTP response message header.
+     */
+    private int maxHttpResponseHeaderSize = -1;
+
+    public int getMaxHttpResponseHeaderSize() {
+        return maxHttpResponseHeaderSize == -1 ? getMaxHttpHeaderSize() : maxHttpResponseHeaderSize;
+    }
+
+    public void setMaxHttpResponseHeaderSize(int valueI) {
+        maxHttpResponseHeaderSize = valueI;
+    }
+
+
     private int connectionUploadTimeout = 300000;
     /**
      * Specifies a different (usually longer) connection timeout during data
diff --git a/java/org/apache/coyote/http11/Http11Processor.java b/java/org/apache/coyote/http11/Http11Processor.java
index eafd286b88..cd4148f4f8 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -190,11 +190,11 @@ public class Http11Processor extends AbstractProcessor {
         httpParser = new HttpParser(protocol.getRelaxedPathChars(),
                 protocol.getRelaxedQueryChars());
 
-        inputBuffer = new Http11InputBuffer(request, protocol.getMaxHttpHeaderSize(),
+        inputBuffer = new Http11InputBuffer(request, protocol.getMaxHttpRequestHeaderSize(),
                 protocol.getRejectIllegalHeader(), httpParser);
         request.setInputBuffer(inputBuffer);
 
-        outputBuffer = new Http11OutputBuffer(response, protocol.getMaxHttpHeaderSize(),
+        outputBuffer = new Http11OutputBuffer(response, protocol.getMaxHttpResponseHeaderSize(),
                 protocol.getSendReasonPhrase());
         response.setOutputBuffer(outputBuffer);
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 9498e8286f..e407303283 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -114,6 +114,17 @@
       </fix>
     </changelog>
   </subsection>
+  <subsection name="Coyote">
+    <changelog>
+      <add>
+        <pr>501</pr>: Add new <code>maxHttpRequestHeaderSize</code> and
+        <code>maxHttpResponseHeaderSize</code> attributes which allow setting
+        the maximum HTTP header sizes independently. If not specified, the
+        value of the <code>maxHttpHeaderSize</code> connector attribute will
+        be used. Submitted by Zhongming Hua. (remm)
+      </add>
+    </changelog>
+  </subsection>
 </section>
 <section name="Tomcat 8.5.78 (markt)" rtext="2022-04-01">
   <subsection name="Catalina">
diff --git a/webapps/docs/config/http.xml b/webapps/docs/config/http.xml
index d85bc3aecc..fd393a777c 100644
--- a/webapps/docs/config/http.xml
+++ b/webapps/docs/config/http.xml
@@ -522,6 +522,18 @@
       in bytes. If not specified, this attribute is set to 8192 (8 KB).</p>
     </attribute>
 
+    <attribute name="maxHttpRequestHeaderSize" required="false">
+      <p>The maximum size of the request HTTP header, specified
+      in bytes. If not specified, this attribute is set to the value of
+      the <code>maxHttpHeaderSize</code> attribute.</p>
+    </attribute>
+
+    <attribute name="maxHttpResponseHeaderSize" required="false">
+      <p>The maximum size of the response HTTP header, specified
+      in bytes. If not specified, this attribute is set to the value of
+      the <code>maxHttpHeaderSize</code> attribute.</p>
+    </attribute>
+
     <attribute name="maxKeepAliveRequests" required="false">
       <p>The maximum number of HTTP requests which can be pipelined until
       the connection is closed by the server. Setting this attribute to 1 will


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