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

jbertram pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new f4cdee69f6 ARTEMIS-5723 Add a setting to disable HTTP/2
f4cdee69f6 is described below

commit f4cdee69f61f858ee23b8159b5f6f38e073b0914
Author: Domenico Francesco Bruscino <[email protected]>
AuthorDate: Tue Oct 28 09:14:02 2025 +0100

    ARTEMIS-5723 Add a setting to disable HTTP/2
---
 .../apache/activemq/artemis/dto/BindingDTO.java    | 11 +++++++++
 .../artemis/component/WebServerComponent.java      | 15 ++++++++----
 .../activemq/cli/test/WebServerComponentTest.java  | 27 ++++++++++++++++++++--
 docs/user-manual/web-server.adoc                   |  4 ++++
 4 files changed, 50 insertions(+), 7 deletions(-)

diff --git 
a/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/BindingDTO.java 
b/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/BindingDTO.java
index 64cb3b5f1e..d9b1441d41 100644
--- a/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/BindingDTO.java
+++ b/artemis-dto/src/main/java/org/apache/activemq/artemis/dto/BindingDTO.java
@@ -84,6 +84,9 @@ public class BindingDTO {
    @XmlAttribute
    private Boolean sslAutoReload;
 
+   @XmlAttribute
+   private Boolean http2;
+
    public String getKeyStorePassword() throws Exception {
       return getPassword(this.keyStorePassword);
    }
@@ -236,6 +239,14 @@ public class BindingDTO {
       this.sslAutoReload = sslAutoReload;
    }
 
+   public Boolean getHttp2() {
+      return http2;
+   }
+
+   public void setHttp2(Boolean http2) {
+      this.http2 = http2;
+   }
+
    public BindingDTO() {
       apps = new ArrayList<>();
    }
diff --git 
a/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
 
b/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
index 6fafd1a548..316b0e3120 100644
--- 
a/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
+++ 
b/artemis-web/src/main/java/org/apache/activemq/artemis/component/WebServerComponent.java
@@ -332,11 +332,16 @@ public class WebServerComponent implements 
ExternalComponent, WebServerComponent
          httpConfiguration.setSendServerVersion(false);
          HttpConnectionFactory httpFactory = new 
HttpConnectionFactory(httpConfiguration);
 
-         HTTP2ServerConnectionFactory h2 = new 
HTTP2ServerConnectionFactory(httpConfiguration);
-         ALPNServerConnectionFactory alpn = new ALPNServerConnectionFactory();
-         alpn.setDefaultProtocol(HttpVersion.HTTP_1_1.asString());
-         SslConnectionFactory sslConnectionFactory = new 
SslConnectionFactory(sslFactory, alpn.getProtocol());
-         connector = new ServerConnector(server, sslConnectionFactory, alpn, 
h2, httpFactory);
+         if (Boolean.FALSE.equals(binding.getHttp2())) {
+            SslConnectionFactory sslConnectionFactory = new 
SslConnectionFactory(sslFactory, HttpVersion.HTTP_1_1.asString());
+            connector = new ServerConnector(server, sslConnectionFactory, 
httpFactory);
+         } else {
+            HTTP2ServerConnectionFactory h2 = new 
HTTP2ServerConnectionFactory(httpConfiguration);
+            ALPNServerConnectionFactory alpn = new 
ALPNServerConnectionFactory();
+            alpn.setDefaultProtocol(HttpVersion.HTTP_1_1.asString());
+            SslConnectionFactory sslConnectionFactory = new 
SslConnectionFactory(sslFactory, alpn.getProtocol());
+            connector = new ServerConnector(server, sslConnectionFactory, 
alpn, h2, httpFactory);
+         }
       } else {
          httpConfiguration.setSendServerVersion(false);
          ConnectionFactory connectionFactory = new 
HttpConnectionFactory(httpConfiguration);
diff --git 
a/artemis-web/src/test/java/org/apache/activemq/cli/test/WebServerComponentTest.java
 
b/artemis-web/src/test/java/org/apache/activemq/cli/test/WebServerComponentTest.java
index deae47205f..d2b512f6e4 100644
--- 
a/artemis-web/src/test/java/org/apache/activemq/cli/test/WebServerComponentTest.java
+++ 
b/artemis-web/src/test/java/org/apache/activemq/cli/test/WebServerComponentTest.java
@@ -108,6 +108,7 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.io.TempDir;
 
+import static java.net.http.HttpClient.Version.HTTP_1_1;
 import static java.net.http.HttpClient.Version.HTTP_2;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -366,7 +367,25 @@ public class WebServerComponentTest extends 
ArtemisTestCase {
 
    @Test
    public void testHttp2() throws Exception {
-      WebServerComponent webServerComponent = startSimpleSecureServer(null, 
null);
+      testWithHttp2Client(null);
+   }
+
+   @Test
+   public void testHttp2Enabled() throws Exception {
+      testWithHttp2Client(true);
+   }
+
+   @Test
+   public void testHttp2Disabled() throws Exception {
+      testWithHttp2Client(false);
+   }
+
+   private void testWithHttp2Client(Boolean http2) throws Exception {
+      BindingDTO bindingDTO = new BindingDTO();
+      bindingDTO.setKeyStorePath(KEY_STORE_PATH);
+      bindingDTO.setKeyStorePassword(KEY_STORE_PASSWORD);
+      bindingDTO.setHttp2(http2);
+      WebServerComponent webServerComponent = 
startSimpleSecureServer(bindingDTO);
       final int port = webServerComponent.getPort();
 
       SSLContext context = new SSLSupport()
@@ -396,7 +415,11 @@ public class WebServerComponentTest extends 
ArtemisTestCase {
       }
 
       assertNotNull(response);
-      assertEquals(HTTP_2, response.version());
+      if (Boolean.FALSE.equals(http2)) {
+         assertEquals(HTTP_1_1, response.version());
+      } else {
+         assertEquals(HTTP_2, response.version());
+      }
       assertEquals(200, response.statusCode());
       assertEquals("12345", response.body());
    }
diff --git a/docs/user-manual/web-server.adoc b/docs/user-manual/web-server.adoc
index 3e354a5117..bd38bfe58e 100644
--- a/docs/user-manual/web-server.adoc
+++ b/docs/user-manual/web-server.adoc
@@ -120,6 +120,10 @@ Whether or not the key and trust store files must be 
watched for changes and aut
 The watch period is controlled by the `scanPeriod` attribute of the `web` 
element, for further details see <<Web>>.
 Default is `false`.
 
+http2::
+Whether or not the HTTP/2 protocol is enabled.
+Default is `true`.
+
 === App
 
 Each web application should be defined in an `app` element inside an `binding` 
element.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to