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

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


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

commit de48ef4877f760dd34ad18e72892e83292b36877
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.
    HTTP/2 should use maxHttpRequestHeaderSize and inherit it, while
    maxHttpResponseHeaderSize will do nothing.
    Submitted by Zhongming Hua.
---
 .../coyote/http11/AbstractHttp11Protocol.java      | 28 ++++++++++++++++++++++
 java/org/apache/coyote/http11/Http11Processor.java |  4 ++--
 java/org/apache/coyote/http2/Http2Protocol.java    |  2 +-
 webapps/docs/changelog.xml                         | 11 +++++++++
 webapps/docs/config/http.xml                       | 12 ++++++++++
 webapps/docs/config/http2.xml                      |  1 +
 6 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/coyote/http11/AbstractHttp11Protocol.java 
b/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
index abcec73eef..4f2776b0d4 100644
--- a/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
+++ b/java/org/apache/coyote/http11/AbstractHttp11Protocol.java
@@ -244,6 +244,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 0fa74b9b5b..4ed8fb47d4 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/java/org/apache/coyote/http2/Http2Protocol.java 
b/java/org/apache/coyote/http2/Http2Protocol.java
index e96a945f0d..46b49d926c 100644
--- a/java/org/apache/coyote/http2/Http2Protocol.java
+++ b/java/org/apache/coyote/http2/Http2Protocol.java
@@ -263,7 +263,7 @@ public class Http2Protocol implements UpgradeProtocol {
 
 
     public int getMaxHeaderSize() {
-        return http11Protocol.getMaxHttpHeaderSize();
+        return http11Protocol.getMaxHttpRequestHeaderSize();
     }
 
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index db4bc415d3..1b4037334d 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 10.0.20 (markt)" rtext="2022-04-01">
   <subsection name="Catalina">
diff --git a/webapps/docs/config/http.xml b/webapps/docs/config/http.xml
index 2245b65a34..1eb51c9987 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
diff --git a/webapps/docs/config/http2.xml b/webapps/docs/config/http2.xml
index b6172ff797..9adacb1d2d 100644
--- a/webapps/docs/config/http2.xml
+++ b/webapps/docs/config/http2.xml
@@ -217,6 +217,7 @@
     <li>compressionMinSize</li>
     <li>maxCookieCount</li>
     <li>maxHttpHeaderSize</li>
+    <li>maxHttpRequestHeaderSize</li>
     <li>maxParameterCount</li>
     <li>maxPostSize</li>
     <li>maxSavePostSize</li>


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

Reply via email to