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

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


The following commit(s) were added to refs/heads/10.1.x by this push:
     new 1f37815c7d Servlet API exposes port as int so parse it as an Integer
1f37815c7d is described below

commit 1f37815c7d77e31ba90df51c4fada4e6742ffb05
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 710cf9a824..196d4df4eb 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 a238fe3254..ed0fad9c92 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