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

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


The following commit(s) were added to refs/heads/11.0.x by this push:
     new d6bc8f6bdd Create a HttpParser if none is found
d6bc8f6bdd is described below

commit d6bc8f6bdd84215394fcb1ed47687a1958130539
Author: remm <r...@apache.org>
AuthorDate: Thu Oct 24 16:55:57 2024 +0200

    Create a HttpParser if none is found
    
    Lifecycle is not enforced in these components, and init actually does
    little (JMX, protocol handlers, upgrade protocols; all likely not used
    and maybe not desired).
    Normally HTTP/2 is always fine since it has to use init to work.
    Reported NPE in Http11InputBuffer from a user with a "working" embedded
    Tomcat before 9.0.93.
---
 java/org/apache/coyote/http11/Http11Processor.java | 16 ++++++++++++++--
 webapps/docs/changelog.xml                         |  7 +++++++
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/http11/Http11Processor.java 
b/java/org/apache/coyote/http11/Http11Processor.java
index 7daa79549a..d34e1772c3 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -146,11 +146,23 @@ public class Http11Processor extends AbstractProcessor {
     private SendfileDataBase sendfileData = null;
 
 
+    /**
+     * Http parser.
+     */
+    private final HttpParser httpParser;
+
+
     public Http11Processor(AbstractHttp11Protocol<?> protocol, Adapter 
adapter) {
         super(adapter);
         this.protocol = protocol;
 
-        inputBuffer = new Http11InputBuffer(request, 
protocol.getMaxHttpRequestHeaderSize(), protocol.getHttpParser());
+        HttpParser httpParser = protocol.getHttpParser();
+        if (httpParser == null) {
+            httpParser = new HttpParser(protocol.getRelaxedPathChars(), 
protocol.getRelaxedQueryChars());
+        }
+        this.httpParser = httpParser;
+
+        inputBuffer = new Http11InputBuffer(request, 
protocol.getMaxHttpRequestHeaderSize(), httpParser);
         request.setInputBuffer(inputBuffer);
 
         outputBuffer = new Http11OutputBuffer(response, 
protocol.getMaxHttpResponseHeaderSize());
@@ -752,7 +764,7 @@ public class Http11Processor extends AbstractProcessor {
         // Validate the characters in the URI. %nn decoding will be checked at
         // the point of decoding.
         for (int i = uriBC.getStart(); i < uriBC.getEnd(); i++) {
-            if (!protocol.getHttpParser().isAbsolutePathRelaxed(uriB[i])) {
+            if (!httpParser.isAbsolutePathRelaxed(uriB[i])) {
                 badRequest("http11processor.request.invalidUri");
                 break;
             }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 5d1810ee06..e897240e96 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -203,6 +203,13 @@
         Align buffer reuse of the OpenSSLEngine for tomcat-native with the FFM
         code. (remm)
       </update>
+      <fix>
+        Create the <code>HttpParser</code> in <code>Http11Processor</code>
+        if it is not present on the <code>AbstractHttp11Protocol</code>
+        to provide better lifecycle robustness for regular HTTP/1.1. The new
+        behavior was introduced on a previous refactoring to improve HTTP/2
+        performance. (remm)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">


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

Reply via email to