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

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


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

commit 431f08b66e27411decb52e1333dd886cc181a854
Author: remm <r...@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 4c64197162..5f7d144536 100644
--- a/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
+++ b/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
@@ -271,6 +271,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 eb9199df80..a401025a83 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -158,11 +158,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());
         response.setOutputBuffer(outputBuffer);
 
         // Create and add the identity filters.
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 92d3ce20e2..76db0f1f13 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 9.0.62 (remm)" rtext="2022-04-01">
   <subsection name="Catalina">
diff --git a/webapps/docs/config/http.xml b/webapps/docs/config/http.xml
index c79a5dc3ba..e01a8666e3 100644
--- a/webapps/docs/config/http.xml
+++ b/webapps/docs/config/http.xml
@@ -518,6 +518,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-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to