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

markt 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 281f16a81a Servlet API exposes port as int so parse it as an Integer
281f16a81a is described below

commit 281f16a81a3d8fa1568fca24c28a1b64398a1e38
Author: Mark Thomas <[email protected]>
AuthorDate: Thu Mar 5 00:17:22 2026 +0000

    Servlet API exposes port as int so parse it as an Integer
---
 java/org/apache/tomcat/util/http/parser/HttpParser.java | 15 ++++++++++++++-
 webapps/docs/changelog.xml                              |  6 ++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/tomcat/util/http/parser/HttpParser.java 
b/java/org/apache/tomcat/util/http/parser/HttpParser.java
index c829be06bd..0a7d156a5e 100644
--- a/java/org/apache/tomcat/util/http/parser/HttpParser.java
+++ b/java/org/apache/tomcat/util/http/parser/HttpParser.java
@@ -488,6 +488,19 @@ public class HttpParser {
         return result.toString();
     }
 
+    /**
+     * @return the number if digits were found, -1 if no data was found or if 
data other than digits was found
+     */
+    static long readInteger(Reader input) throws IOException {
+        String digits = readDigits(input);
+
+        if (digits.isEmpty()) {
+            return -1;
+        }
+
+        return Integer.parseInt(digits);
+    }
+
     /**
      * @return the number if digits were found, -1 if no data was found or if 
data other than digits was found
      */
@@ -943,7 +956,7 @@ public class HttpParser {
 
     static int validatePort(Reader reader, int colonPosition) throws 
IOException {
         // Remaining characters should be numeric ...
-        readLong(reader);
+        readInteger(reader);
         // ... followed by EOS
         if (reader.read() == -1) {
             return colonPosition;
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 6c6dce01f9..b5cba3f45d 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -171,6 +171,12 @@
         Improve HPACK exception use, making sure <code>HpackException</code>
         is thrown instead of unexpected types. (remm)
       </fix>
+      <fix>
+        Update the parser for the HTTP <code>Host</code> header and
+        <code>:authority</code> pseudo header to convert the port, if any, to 
an
+        <code>Integer</code> rather than a <code>Long</code> to be consistent
+        with how port is exposed in the Servlet API. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to