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

fanningpj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-http.git


The following commit(s) were added to refs/heads/main by this push:
     new ba42da413 enable http/2 by default (#928)
ba42da413 is described below

commit ba42da413353f46049553ec6a9d0f3414dd6c07e
Author: PJ Fanning <[email protected]>
AuthorDate: Thu Feb 26 13:29:22 2026 +0100

    enable http/2 by default (#928)
    
    * enable http/2 by default
    
    * broken test
---
 docs/src/main/paradox/server-side/http2.md         |  4 +++-
 http-core/src/main/resources/reference.conf        |  8 ++++---
 .../http/impl/settings/ServerSettingsImpl.scala    |  2 +-
 .../scaladsl/settings/ServerSettingsSpec.scala     | 27 +++++++++++++++-------
 .../pekko/http/javadsl/Http2JavaServerTest.java    |  3 +--
 .../impl/engine/http2/H2SpecIntegrationSpec.scala  |  1 -
 .../http/impl/engine/http2/H2cUpgradeSpec.scala    |  1 -
 .../impl/engine/http2/Http2ClientServerSpec.scala  |  1 -
 .../engine/http2/Http2PersistentClientSpec.scala   |  3 ---
 .../http/impl/engine/http2/TelemetrySpiSpec.scala  |  1 -
 .../impl/engine/http2/WithPriorKnowledgeSpec.scala |  1 -
 .../pekko/http/scaladsl/Http2ServerTest.scala      |  4 +---
 12 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/docs/src/main/paradox/server-side/http2.md 
b/docs/src/main/paradox/server-side/http2.md
index b5aa37269..335d367e0 100644
--- a/docs/src/main/paradox/server-side/http2.md
+++ b/docs/src/main/paradox/server-side/http2.md
@@ -2,12 +2,14 @@
 
 ## Enable HTTP/2 support
 
-HTTP/2 can then be enabled through configuration:
+HTTP/2 is enabled through configuration:
 
 ```
 pekko.http.server.enable-http2 = on
 ```
 
+Since Pekko HTTP 2.0.0, this defaults to `on`.
+
 ## Use `newServerAt(...).bind()` and HTTPS
 
 HTTP/2 is primarily used over a secure HTTPS connection which takes care of 
protocol negotiation and falling back to HTTP/1.1 over TLS when the client does 
not support HTTP/2.
diff --git a/http-core/src/main/resources/reference.conf 
b/http-core/src/main/resources/reference.conf
index fb2c89a29..81f1aa903 100644
--- a/http-core/src/main/resources/reference.conf
+++ b/http-core/src/main/resources/reference.conf
@@ -27,7 +27,8 @@ pekko.http {
     #
     # Note that this setting is intended to replace 
`pekko.http.server.preview.enable-http2`
     # but that setting is still supported for compatibility reasons.
-    enable-http2 = off
+    # The default value changed to `on` in Pekko HTTP 2.0.0.
+    enable-http2 = on
 
     # "PREVIEW" features that are not yet fully production ready.
     # These flags can change or be removed between patch releases.
@@ -37,8 +38,9 @@ pekko.http {
       #
       # `Http().newServerAt(...).bindFlow` and `connectionSource()` are not 
supported.
       #
-      # Note that this setting is ignored if `pekko.http.server.enable-http2` 
is set to `on`.
-      enable-http2 = ${pekko.http.server.enable-http2}
+      # Note that this setting is expected to be null or a boolean or 
`on`/`off`.
+      # It is ignored if `pekko.http.server.enable-http2` is set to `on`.
+      enable-http2 = null
     }
 
     # The time after which an idle connection will be automatically closed.
diff --git 
a/http-core/src/main/scala/org/apache/pekko/http/impl/settings/ServerSettingsImpl.scala
 
b/http-core/src/main/scala/org/apache/pekko/http/impl/settings/ServerSettingsImpl.scala
index c263f1376..5dd81280a 100644
--- 
a/http-core/src/main/scala/org/apache/pekko/http/impl/settings/ServerSettingsImpl.scala
+++ 
b/http-core/src/main/scala/org/apache/pekko/http/impl/settings/ServerSettingsImpl.scala
@@ -123,7 +123,7 @@ private[http] object ServerSettingsImpl extends 
SettingsCompanionImpl[ServerSett
       terminationDeadlineExceededResponseFrom(c),
       c.getString("parsing.error-handler"),
       c.getFiniteDuration("stream-cancellation-delay"),
-      c.getBoolean("enable-http2") || c.getBoolean("preview.enable-http2"))
+      c.getBoolean("enable-http2") || (c.hasPath("preview.enable-http2") && 
c.getBoolean("preview.enable-http2")))
   }
 
   private def terminationDeadlineExceededResponseFrom(c: Config): HttpResponse 
= {
diff --git 
a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/ServerSettingsSpec.scala
 
b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/ServerSettingsSpec.scala
index 9c1b72a63..5ccd63ccc 100644
--- 
a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/ServerSettingsSpec.scala
+++ 
b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/ServerSettingsSpec.scala
@@ -33,36 +33,47 @@ class ServerSettingsSpec extends PekkoSpec {
       }
       e.getMessage should include("does not contain the server-specific 
settings")
     }
-    "default enableHttp2 to false" in {
+    "default enableHttp2 to true" in {
       val serverSettings = ServerSettings(system)
-      serverSettings.enableHttp2 should ===(false)
+      serverSettings.enableHttp2 should ===(true)
     }
-    "set enableHttp2 to true if preview.enable-http2 is on" in {
+    "set enableHttp2 to false if enable-http2 is off" in {
       val cfg = ConfigFactory.parseString("""
         pekko.http.server {
-          preview.enable-http2 = on
+          enable-http2 = off
         }
       """).withFallback(system.settings.config)
       val serverSettings = ServerSettings(cfg)
-      serverSettings.enableHttp2 should ===(true)
+      serverSettings.enableHttp2 should ===(false)
     }
-    "set enableHttp2 to true if enable-http2 is on" in {
+    "set enableHttp2 to true if enable-http2 is on and preview.enable-http2 is 
off" in {
       val cfg = ConfigFactory.parseString("""
         pekko.http.server {
           enable-http2 = on
+          preview.enable-http2 = off
         }
       """).withFallback(system.settings.config)
       val serverSettings = ServerSettings(cfg)
       serverSettings.enableHttp2 should ===(true)
     }
-    "set enableHttp2 to true if enable-http2 is on and preview.enable-http2 is 
off" in {
+    "set enableHttp2 to false if enable-http2 is off and preview.enable-http2 
is off" in {
       val cfg = ConfigFactory.parseString("""
         pekko.http.server {
-          enable-http2 = on
+          enable-http2 = off
           preview.enable-http2 = off
         }
       """).withFallback(system.settings.config)
       val serverSettings = ServerSettings(cfg)
+      serverSettings.enableHttp2 should ===(false)
+    }
+    "set enableHttp2 to true if enable-http2 is off and preview.enable-http2 
is on" in {
+      val cfg = ConfigFactory.parseString("""
+        pekko.http.server {
+          enable-http2 = off
+          preview.enable-http2 = on
+        }
+      """).withFallback(system.settings.config)
+      val serverSettings = ServerSettings(cfg)
       serverSettings.enableHttp2 should ===(true)
     }
   }
diff --git 
a/http2-tests/src/test/java/org/apache/pekko/http/javadsl/Http2JavaServerTest.java
 
b/http2-tests/src/test/java/org/apache/pekko/http/javadsl/Http2JavaServerTest.java
index 8ad281779..c18724ee7 100644
--- 
a/http2-tests/src/test/java/org/apache/pekko/http/javadsl/Http2JavaServerTest.java
+++ 
b/http2-tests/src/test/java/org/apache/pekko/http/javadsl/Http2JavaServerTest.java
@@ -34,8 +34,7 @@ public class Http2JavaServerTest {
                 + "pekko.actor.serialize-creators = off\n"
                 + "pekko.actor.serialize-messages = off\n"
                 + "#pekko.actor.default-dispatcher.throughput = 1000\n"
-                + 
"pekko.actor.default-dispatcher.fork-join-executor.parallelism-max=8\n"
-                + "pekko.http.server.enable-http2 = on\n");
+                + 
"pekko.actor.default-dispatcher.fork-join-executor.parallelism-max=8\n");
     ActorSystem system = ActorSystem.create("ServerTest", testConf);
 
     Function<HttpRequest, CompletionStage<HttpResponse>> handler =
diff --git 
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/H2SpecIntegrationSpec.scala
 
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/H2SpecIntegrationSpec.scala
index 6f64e97b1..e80cd87f4 100644
--- 
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/H2SpecIntegrationSpec.scala
+++ 
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/H2SpecIntegrationSpec.scala
@@ -35,7 +35,6 @@ class H2SpecIntegrationSpec extends PekkoFreeSpec(
        loglevel = DEBUG
        loggers = 
["org.apache.pekko.http.impl.util.SilenceAllTestEventListener"]
        http.server.log-unencrypted-network-bytes = 100
-       http.server.enable-http2 = on
        http.server.http2.log-frames = on
 
        actor.serialize-creators = off
diff --git 
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/H2cUpgradeSpec.scala
 
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/H2cUpgradeSpec.scala
index 555e627ec..a8e5035ec 100644
--- 
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/H2cUpgradeSpec.scala
+++ 
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/H2cUpgradeSpec.scala
@@ -27,7 +27,6 @@ import pekko.stream.scaladsl.{ Source, Tcp }
 import pekko.util.ByteString
 
 class H2cUpgradeSpec extends PekkoSpecWithMaterializer("""
-    pekko.http.server.enable-http2 = on
     pekko.http.server.http2.log-frames = on
   """) {
 
diff --git 
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ClientServerSpec.scala
 
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ClientServerSpec.scala
index 75c8d9f5f..3885c8ffe 100644
--- 
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ClientServerSpec.scala
+++ 
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ClientServerSpec.scala
@@ -52,7 +52,6 @@ import org.scalatest.concurrent.ScalaFutures
 class Http2ClientServerSpec extends PekkoSpecWithMaterializer(
       """pekko.http.server.http2.log-frames = on
      pekko.http.server.log-unencrypted-network-bytes = 100
-     pekko.http.server.enable-http2 = on
      pekko.http.client.http2.log-frames = on
      pekko.http.client.log-unencrypted-network-bytes = 100
      pekko.actor.serialize-messages = false
diff --git 
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2PersistentClientSpec.scala
 
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2PersistentClientSpec.scala
index b9e25cfb6..fcaa2b57b 100644
--- 
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2PersistentClientSpec.scala
+++ 
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2PersistentClientSpec.scala
@@ -59,10 +59,7 @@ class Http2PersistentClientTlsSpec extends 
Http2PersistentClientSpec(true)
 class Http2PersistentClientPlaintextSpec extends 
Http2PersistentClientSpec(false)
 
 abstract class Http2PersistentClientSpec(tls: Boolean) extends 
PekkoSpecWithMaterializer(
-      // FIXME: would rather use remote-address-attribute, but that doesn't 
work with HTTP/2
-      // see https://github.com/akka/akka-http/issues/3707
       """pekko.http.server.remote-address-attribute = on
-     pekko.http.server.enable-http2 = on
      pekko.http.client.http2.log-frames = on
      pekko.http.client.http2.max-persistent-attempts = 5
      pekko.http.client.log-unencrypted-network-bytes = 100
diff --git 
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/TelemetrySpiSpec.scala
 
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/TelemetrySpiSpec.scala
index c0c35b11f..f6f72cdb1 100644
--- 
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/TelemetrySpiSpec.scala
+++ 
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/TelemetrySpiSpec.scala
@@ -68,7 +68,6 @@ class TelemetrySpiCypherSpec extends TelemetrySpiSpec(true)
 
 abstract class TelemetrySpiSpec(useTls: Boolean) extends 
PekkoSpecWithMaterializer(
       """
-     pekko.http.server.enable-http2 = on
      pekko.actor.serialize-messages = false
      pekko.http.http2-telemetry-class = 
"org.apache.pekko.http.impl.engine.http2.TestTelemetryImpl"
   """) with ScalaFutures with BeforeAndAfterAll {
diff --git 
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/WithPriorKnowledgeSpec.scala
 
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/WithPriorKnowledgeSpec.scala
index 931ba08a4..a9a8114d3 100644
--- 
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/WithPriorKnowledgeSpec.scala
+++ 
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/WithPriorKnowledgeSpec.scala
@@ -27,7 +27,6 @@ import pekko.stream.scaladsl.Sink
 import pekko.util.ByteString
 
 class WithPriorKnowledgeSpec extends PekkoSpecWithMaterializer("""
-    pekko.http.server.enable-http2 = on
     pekko.http.server.http2.log-frames = on
   """) {
 
diff --git 
a/http2-tests/src/test/scala/org/apache/pekko/http/scaladsl/Http2ServerTest.scala
 
b/http2-tests/src/test/scala/org/apache/pekko/http/scaladsl/Http2ServerTest.scala
index 588bbf7be..e56da5329 100644
--- 
a/http2-tests/src/test/scala/org/apache/pekko/http/scaladsl/Http2ServerTest.scala
+++ 
b/http2-tests/src/test/scala/org/apache/pekko/http/scaladsl/Http2ServerTest.scala
@@ -43,9 +43,7 @@ object Http2ServerTest extends App {
     pekko.actor.serialize-creators = off
     pekko.actor.serialize-messages = off
     #pekko.actor.default-dispatcher.throughput = 1000
-    pekko.actor.default-dispatcher.fork-join-executor.parallelism-max=8
-    pekko.http.server.enable-http2 = true
-                                                   """)
+    pekko.actor.default-dispatcher.fork-join-executor.parallelism-max=8""")
   implicit val system: ActorSystem = ActorSystem("ServerTest", testConf)
   implicit val ec: ExecutionContext = system.dispatcher
 


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

Reply via email to