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

dsoumis 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 311148f778 Add TestAlpnFallback
311148f778 is described below

commit 311148f77838fdf4dbc4211c904e46f14bc18e5f
Author: Dimitris Soumis <[email protected]>
AuthorDate: Fri Mar 20 13:33:16 2026 +0200

    Add TestAlpnFallback
---
 .../apache/tomcat/util/net/TestAlpnFallback.java   | 52 ++++++++++++++++++++++
 test/org/apache/tomcat/util/net/TesterSupport.java |  2 +-
 2 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/test/org/apache/tomcat/util/net/TestAlpnFallback.java 
b/test/org/apache/tomcat/util/net/TestAlpnFallback.java
new file mode 100644
index 0000000000..45f6fbf7a2
--- /dev/null
+++ b/test/org/apache/tomcat/util/net/TestAlpnFallback.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tomcat.util.net;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.catalina.Context;
+import org.apache.catalina.startup.Tomcat;
+import org.apache.coyote.http2.Http2TestBase;
+import org.apache.tomcat.util.buf.ByteChunk;
+
+public class TestAlpnFallback extends Http2TestBase {
+
+    @Test
+    public void testAlpnFallbackToHttp11() throws Exception {
+        TesterSupport.configureClientSsl();
+        //There's no ALPN negotiation without TLS
+        enableHttp2(true);
+
+        Tomcat tomcat = getTomcatInstance();
+
+        Context ctx = getProgrammaticRootContext();
+        Tomcat.addServlet(ctx, "snoop", new SnoopServlet());
+        ctx.addServletMappingDecoded("/", "snoop");
+
+        tomcat.start();
+
+        // HttpURLConnection does not support ALPN, so this request will 
connect over TLS without negotiating h2.
+        // The connector must fall back to HTTP/1.1 rather than dropping the 
connection.
+        ByteChunk res = new ByteChunk();
+        getUrl("https://localhost:"; + getPort() + "/", res, null);
+        RequestDescriptor requestDesc = SnoopResult.parse(res.toString());
+        Assert.assertEquals("HTTP/1.1", 
requestDesc.getRequestInfo("REQUEST-PROTOCOL"));
+    }
+
+}
diff --git a/test/org/apache/tomcat/util/net/TesterSupport.java 
b/test/org/apache/tomcat/util/net/TesterSupport.java
index 2f146990db..d38b233e32 100644
--- a/test/org/apache/tomcat/util/net/TesterSupport.java
+++ b/test/org/apache/tomcat/util/net/TesterSupport.java
@@ -128,7 +128,7 @@ public final class TesterSupport {
     }
 
     public static void initSsl(Tomcat tomcat) {
-        // By default, use JSSE JSSE trust
+        // By default, use JSSE trust
         initSsl(tomcat, false);
     }
 


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

Reply via email to