From 12d5c819fb9b0a104c3732ec1e8ee46241ccdbac Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Fri, 3 Oct 2025 06:41:06 +0100 Subject: [PATCH 1/5] add pekko.http.server.enable-http2 config --- http-core/src/main/resources/reference.conf | 10 +++++++++- .../http/impl/settings/ServerSettingsImpl.scala | 12 ++++++++---- .../javadsl/settings/PreviewServerSettings.scala | 4 ++++ .../http/javadsl/settings/ServerSettings.scala | 8 ++++++++ .../org/apache/pekko/http/scaladsl/Http.scala | 6 +++--- .../scaladsl/settings/PreviewServerSettings.scala | 3 +++ .../http/scaladsl/settings/ServerSettings.scala | 15 +++++++++++++++ .../pekko/http/scaladsl/ClientServerSpec.scala | 2 +- .../pekko/http/javadsl/Http2JavaServerTest.java | 2 +- .../impl/engine/http2/H2SpecIntegrationSpec.scala | 2 +- .../http/impl/engine/http2/H2cUpgradeSpec.scala | 2 +- .../impl/engine/http2/Http2ClientServerSpec.scala | 2 +- .../engine/http2/Http2PersistentClientSpec.scala | 2 +- .../http/impl/engine/http2/TelemetrySpiSpec.scala | 2 +- .../engine/http2/WithPriorKnowledgeSpec.scala | 2 +- .../pekko/http/scaladsl/Http2ServerTest.scala | 2 +- 16 files changed, 59 insertions(+), 17 deletions(-) diff --git a/http-core/src/main/resources/reference.conf b/http-core/src/main/resources/reference.conf index fae5ac0b1..12c7c3a18 100644 --- a/http-core/src/main/resources/reference.conf +++ b/http-core/src/main/resources/reference.conf @@ -20,6 +20,12 @@ pekko.http { # the request, no `Server` header will be rendered at all. server-header = pekko-http/${pekko.http.version} + # If this setting is enabled `Http().newServerAt(...).bind` and `bindSync` + # will be enabled to use HTTP/2. + # + # `Http().newServerAt(...).bindFlow` and `connectionSource()` are not supported. + enable-http2 = off + # "PREVIEW" features that are not yet fully production ready. # These flags can change or be removed between patch releases. preview { @@ -27,7 +33,9 @@ pekko.http { # will be enabled to use HTTP/2. # # `Http().newServerAt(...).bindFlow` and `connectionSource()` are not supported. - enable-http2 = off + # + # Note that this setting is ignored if `pekko.http.server.enable-http2` is set to `on`. + enable-http2 = ${pekko.http.server.enable-http2} } # 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 273645f53..91782018d 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 @@ -14,6 +14,7 @@ package org.apache.pekko.http.impl.settings import scala.language.implicitConversions +import scala.annotation.nowarn import scala.collection.immutable import scala.concurrent.duration._ import scala.util.Try @@ -36,7 +37,7 @@ import pekko.io.Inet.SocketOption @InternalApi private[pekko] final case class ServerSettingsImpl( serverHeader: Option[Server], - previewServerSettings: PreviewServerSettings, + @nowarn("msg=deprecated") previewServerSettings: PreviewServerSettings, timeouts: ServerSettings.Timeouts, maxConnections: Int, pipeliningLimit: Int, @@ -56,7 +57,8 @@ private[pekko] final case class ServerSettingsImpl( defaultHttpsPort: Int, terminationDeadlineExceededResponse: HttpResponse, parsingErrorHandler: String, - streamCancellationDelay: FiniteDuration) extends ServerSettings { + streamCancellationDelay: FiniteDuration, + enableHttp2: Boolean) extends ServerSettings { require(0 < maxConnections, "max-connections must be > 0") require(0 < pipeliningLimit && pipeliningLimit <= 1024, "pipelining-limit must be > 0 and <= 1024") @@ -90,9 +92,10 @@ private[http] object ServerSettingsImpl extends SettingsCompanionImpl[ServerSett def fromSubConfig(root: Config, c: Config) = { val parserSettings = ParserSettingsImpl.fromSubConfig(root, c.getConfig("parsing")) + val previewSettings = PreviewServerSettingsImpl.fromSubConfig(root, c.getConfig("preview")) new ServerSettingsImpl( c.getString("server-header").toOption.map(Server(_)), - PreviewServerSettingsImpl.fromSubConfig(root, c.getConfig("preview")), + previewSettings, Timeouts( c.getPotentiallyInfiniteDuration("idle-timeout"), if (c.getString("request-timeout") == "off") Duration.Zero @@ -123,7 +126,8 @@ private[http] object ServerSettingsImpl extends SettingsCompanionImpl[ServerSett c.getInt("default-https-port"), terminationDeadlineExceededResponseFrom(c), c.getString("parsing.error-handler"), - c.getFiniteDuration("stream-cancellation-delay")) + c.getFiniteDuration("stream-cancellation-delay"), + c.getBoolean("enable-http2") || previewSettings.enableHttp2) } private def terminationDeadlineExceededResponseFrom(c: Config): HttpResponse = { diff --git a/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/PreviewServerSettings.scala b/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/PreviewServerSettings.scala index b69e528f9..44de8d4c3 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/PreviewServerSettings.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/PreviewServerSettings.scala @@ -25,8 +25,12 @@ import com.typesafe.config.Config * Options that are in "preview" or "early access" mode. * These options may change and/or be removed within patch releases * without early notice (e.g. by moving them into a stable supported place). + * + * @deprecated PreviewServerSettings is deprecated, use pekko.http.javadsl.settings.ServerSettings instead (since 2.0.0) */ @ApiMayChange @DoNotInherit +@Deprecated +@deprecated("PreviewServerSettings is deprecated, use pekko.http.javadsl.settings.ServerSettings instead", "2.0.0") abstract class PreviewServerSettings private[pekko] () { self: PreviewServerSettingsImpl => /** diff --git a/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSettings.scala b/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSettings.scala index 15ca39707..013507adf 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSettings.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSettings.scala @@ -34,6 +34,7 @@ import scala.concurrent.duration.{ Duration, FiniteDuration } */ @DoNotInherit abstract class ServerSettings { self: ServerSettingsImpl => def getServerHeader: Optional[Server] + @deprecated("the preview server settings are now integrated into the main server settings", "2.0.0") def getPreviewServerSettings: PreviewServerSettings def getTimeouts: ServerSettings.Timeouts def getMaxConnections: Int @@ -55,11 +56,17 @@ import scala.concurrent.duration.{ Duration, FiniteDuration } def getTerminationDeadlineExceededResponse: pekko.http.javadsl.model.HttpResponse def getParsingErrorHandler: String def getStreamCancellationDelay: FiniteDuration + /** + * Configures the Http extension to bind using HTTP/2 if given an + * [[pekko.http.scaladsl.HttpsConnectionContext]]. Otherwise binds as plain HTTP. + */ + def enableHttp2: Boolean // --- def withServerHeader(newValue: Optional[Server]): ServerSettings = self.copy(serverHeader = newValue.toScala.map(_.asScala)) + @deprecated("the preview server settings are now integrated into the main server settings", "2.0.0") def withPreviewServerSettings(newValue: PreviewServerSettings): ServerSettings = self.copy(previewServerSettings = newValue.asScala) def withTimeouts(newValue: ServerSettings.Timeouts): ServerSettings = self.copy(timeouts = newValue.asScala) @@ -87,6 +94,7 @@ import scala.concurrent.duration.{ Duration, FiniteDuration } def withParsingErrorHandler(newValue: String): ServerSettings = self.copy(parsingErrorHandler = parsingErrorHandler) def withStreamCancellationDelay(newValue: FiniteDuration): ServerSettings = self.copy(streamCancellationDelay = newValue) + def withEnableHttp2(newValue: Boolean): ServerSettings = self.copy(enableHttp2 = newValue) } object ServerSettings extends SettingsCompanion[ServerSettings] { diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/Http.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/Http.scala index 17a5044a1..6a7f2692d 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/Http.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/Http.scala @@ -180,7 +180,7 @@ class HttpExt @InternalStableApi /* constructor signature is hardcoded in Teleme connectionContext: ConnectionContext, settings: ServerSettings, log: LoggingAdapter): Source[Http.IncomingConnection, Future[ServerBinding]] = { - if (settings.previewServerSettings.enableHttp2) + if (settings.enableHttp2) log.warning( s"Binding with a connection source not supported with HTTP/2. Falling back to HTTP/1.1 for port [$port]") @@ -221,7 +221,7 @@ class HttpExt @InternalStableApi /* constructor signature is hardcoded in Teleme connectionContext: ConnectionContext, settings: ServerSettings, log: LoggingAdapter)(implicit fm: Materializer): Future[ServerBinding] = { - if (settings.previewServerSettings.enableHttp2) + if (settings.enableHttp2) log.warning( s"Binding with a connection source not supported with HTTP/2. Falling back to HTTP/1.1 for port [$port].") @@ -282,7 +282,7 @@ class HttpExt @InternalStableApi /* constructor signature is hardcoded in Teleme settings: ServerSettings, parallelism: Int, log: LoggingAdapter)(implicit fm: Materializer): Future[ServerBinding] = { - if (settings.previewServerSettings.enableHttp2) { + if (settings.enableHttp2) { log.debug("Binding server using HTTP/2") val definitiveSettings = diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/PreviewServerSettings.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/PreviewServerSettings.scala index acba1b782..5bcac07b7 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/PreviewServerSettings.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/PreviewServerSettings.scala @@ -24,8 +24,11 @@ import com.typesafe.config.Config * Options that are in "preview" or "early access" mode. * These options may change and/or be removed within patch releases * without early notice (e.g. by moving them into a stable supported place). + * + * @deprecated PreviewServerSettings is deprecated, use pekko.http.scaladsl.settings.ServerSettings instead (since 2.0.0) */ @ApiMayChange @DoNotInherit +@deprecated("PreviewServerSettings is deprecated, use pekko.http.scaladsl.settings.ServerSettings instead", "2.0.0") abstract class PreviewServerSettings private[pekko] () extends org.apache.pekko.http.javadsl.settings.PreviewServerSettings { self: PreviewServerSettingsImpl => diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ServerSettings.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ServerSettings.scala index a655e8448..4b788b3fa 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ServerSettings.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ServerSettings.scala @@ -60,10 +60,19 @@ abstract class ServerSettings private[pekko] () extends pekko.http.javadsl.setti def terminationDeadlineExceededResponse: HttpResponse def parsingErrorHandler: String def streamCancellationDelay: FiniteDuration + /** + * @since 2.0.0 + */ + def enableHttp2: Boolean /* Java APIs */ override def getBacklog = this.backlog + /** + * @deprecated the preview server settings are now integrated into the main server settings (since 2.0.0) + */ + @Deprecated + @deprecated("the preview server settings are now integrated into the main server settings", "2.0.0") override def getPreviewServerSettings: pekko.http.javadsl.settings.PreviewServerSettings = this.previewServerSettings override def getDefaultHostHeader = this.defaultHostHeader.asJava override def getPipeliningLimit = this.pipeliningLimit @@ -87,6 +96,11 @@ abstract class ServerSettings private[pekko] () extends pekko.http.javadsl.setti // --- // override for more specific return type + /** + * @deprecated the preview server settings are now integrated into the main server settings (since 2.0.0) + */ + @Deprecated + @deprecated("the preview server settings are now integrated into the main server settings", "2.0.0") def withPreviewServerSettings(newValue: PreviewServerSettings): ServerSettings = self.copy(previewServerSettings = newValue) override def withMaxConnections(newValue: Int): ServerSettings = self.copy(maxConnections = newValue) @@ -110,6 +124,7 @@ abstract class ServerSettings private[pekko] () extends pekko.http.javadsl.setti override def withParsingErrorHandler(newValue: String): ServerSettings = self.copy(parsingErrorHandler = newValue) override def withStreamCancellationDelay(newValue: FiniteDuration): ServerSettings = self.copy(streamCancellationDelay = newValue) + override def withEnableHttp2(newValue: Boolean): ServerSettings = self.copy(enableHttp2 = newValue) // overloads for Scala idiomatic use def withTimeouts(newValue: ServerSettings.Timeouts): ServerSettings = self.copy(timeouts = newValue) diff --git a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/ClientServerSpec.scala b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/ClientServerSpec.scala index 9f8649d46..e53091199 100644 --- a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/ClientServerSpec.scala +++ b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/ClientServerSpec.scala @@ -58,7 +58,7 @@ class ClientServerHttp2EnabledSpec extends ClientServerSpecBase(http2 = true) abstract class ClientServerSpecBase(http2: Boolean) extends PekkoSpecWithMaterializer( s""" - pekko.http.server.preview.enable-http2 = $http2 + pekko.http.server.enable-http2 = $http2 pekko.http.server.request-timeout = infinite pekko.http.server.log-unencrypted-network-bytes = 200 pekko.http.client.log-unencrypted-network-bytes = 200 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 86b822477..8ad281779 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 @@ -35,7 +35,7 @@ public static void main(String[] args) { + "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.preview.enable-http2 = on\n"); + + "pekko.http.server.enable-http2 = on\n"); ActorSystem system = ActorSystem.create("ServerTest", testConf); Function> 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 63bfb35ef..9907cbf60 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,7 @@ class H2SpecIntegrationSpec extends PekkoFreeSpec( loglevel = DEBUG loggers = ["org.apache.pekko.http.impl.util.SilenceAllTestEventListener"] http.server.log-unencrypted-network-bytes = 100 - http.server.preview.enable-http2 = on + 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 34c0a7413..555e627ec 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,7 @@ import pekko.stream.scaladsl.{ Source, Tcp } import pekko.util.ByteString class H2cUpgradeSpec extends PekkoSpecWithMaterializer(""" - pekko.http.server.preview.enable-http2 = on + 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 b46ab3c00..75c8d9f5f 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,7 @@ 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.preview.enable-http2 = on + 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 9c5d60b4d..b9e25cfb6 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 @@ -62,7 +62,7 @@ abstract class Http2PersistentClientSpec(tls: Boolean) extends PekkoSpecWithMate // 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.preview.enable-http2 = 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 0e3ffe4d2..5a0d07cf1 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,7 @@ class TelemetrySpiCypherSpec extends TelemetrySpiSpec(true) abstract class TelemetrySpiSpec(useTls: Boolean) extends PekkoSpecWithMaterializer( """ - pekko.http.server.preview.enable-http2 = on + 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 258493cbf..931ba08a4 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,7 @@ import pekko.stream.scaladsl.Sink import pekko.util.ByteString class WithPriorKnowledgeSpec extends PekkoSpecWithMaterializer(""" - pekko.http.server.preview.enable-http2 = on + 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 f82f180ae..c6d049e48 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 @@ -44,7 +44,7 @@ object Http2ServerTest extends App { pekko.actor.serialize-messages = off #pekko.actor.default-dispatcher.throughput = 1000 pekko.actor.default-dispatcher.fork-join-executor.parallelism-max=8 - pekko.http.server.preview.enable-http2 = true + pekko.http.server.enable-http2 = true """) implicit val system: ActorSystem = ActorSystem("ServerTest", testConf) implicit val ec: ExecutionContext = system.dispatcher From 17b6de1fa2c1504dfa03c2d07f3f2942d800243f Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Fri, 3 Oct 2025 06:46:23 +0100 Subject: [PATCH 2/5] scalafmt --- http-core/src/main/resources/reference.conf | 3 +++ .../pekko/http/javadsl/settings/ServerSettings.scala | 1 + .../http/scaladsl/settings/PreviewServerSettings.scala | 2 +- .../pekko/http/scaladsl/settings/ServerSettings.scala | 10 ++++++---- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/http-core/src/main/resources/reference.conf b/http-core/src/main/resources/reference.conf index 12c7c3a18..fb2c89a29 100644 --- a/http-core/src/main/resources/reference.conf +++ b/http-core/src/main/resources/reference.conf @@ -24,6 +24,9 @@ pekko.http { # will be enabled to use HTTP/2. # # `Http().newServerAt(...).bindFlow` and `connectionSource()` are not supported. + # + # 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 # "PREVIEW" features that are not yet fully production ready. diff --git a/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSettings.scala b/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSettings.scala index 013507adf..36a23b7b2 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSettings.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSettings.scala @@ -56,6 +56,7 @@ import scala.concurrent.duration.{ Duration, FiniteDuration } def getTerminationDeadlineExceededResponse: pekko.http.javadsl.model.HttpResponse def getParsingErrorHandler: String def getStreamCancellationDelay: FiniteDuration + /** * Configures the Http extension to bind using HTTP/2 if given an * [[pekko.http.scaladsl.HttpsConnectionContext]]. Otherwise binds as plain HTTP. diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/PreviewServerSettings.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/PreviewServerSettings.scala index 5bcac07b7..5c513538f 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/PreviewServerSettings.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/PreviewServerSettings.scala @@ -24,7 +24,7 @@ import com.typesafe.config.Config * Options that are in "preview" or "early access" mode. * These options may change and/or be removed within patch releases * without early notice (e.g. by moving them into a stable supported place). - * + * * @deprecated PreviewServerSettings is deprecated, use pekko.http.scaladsl.settings.ServerSettings instead (since 2.0.0) */ @ApiMayChange @DoNotInherit diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ServerSettings.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ServerSettings.scala index 4b788b3fa..cf8f717ca 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ServerSettings.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ServerSettings.scala @@ -60,17 +60,19 @@ abstract class ServerSettings private[pekko] () extends pekko.http.javadsl.setti def terminationDeadlineExceededResponse: HttpResponse def parsingErrorHandler: String def streamCancellationDelay: FiniteDuration + /** - * @since 2.0.0 - */ + * @since 2.0.0 + */ def enableHttp2: Boolean /* Java APIs */ override def getBacklog = this.backlog + /** - * @deprecated the preview server settings are now integrated into the main server settings (since 2.0.0) - */ + * @deprecated the preview server settings are now integrated into the main server settings (since 2.0.0) + */ @Deprecated @deprecated("the preview server settings are now integrated into the main server settings", "2.0.0") override def getPreviewServerSettings: pekko.http.javadsl.settings.PreviewServerSettings = this.previewServerSettings From a90fd70aa9434f7a0e7d3d9ea2c15087b9996098 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Fri, 3 Oct 2025 07:01:46 +0100 Subject: [PATCH 3/5] mima --- .../http2-out-of-preview.excludes | 20 +++++++++++++++++++ .../settings/PreviewServerSettings.scala | 4 ++-- .../javadsl/settings/ServerSettings.scala | 4 ++-- .../settings/PreviewServerSettings.scala | 4 ++-- .../scaladsl/settings/ServerSettings.scala | 10 +++++----- 5 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 http-core/src/main/mima-filters/1.3.x.backwards.excludes/http2-out-of-preview.excludes diff --git a/http-core/src/main/mima-filters/1.3.x.backwards.excludes/http2-out-of-preview.excludes b/http-core/src/main/mima-filters/1.3.x.backwards.excludes/http2-out-of-preview.excludes new file mode 100644 index 000000000..61efca5c8 --- /dev/null +++ b/http-core/src/main/mima-filters/1.3.x.backwards.excludes/http2-out-of-preview.excludes @@ -0,0 +1,20 @@ +# 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. + +# HTTP/2 is no longer in preview +ProblemFilters.exclude[ReversedMissingMethodProblem]("org.apache.pekko.http.javadsl.settings.ServerSettings.enableHttp2") +ProblemFilters.exclude[ReversedMissingMethodProblem]("org.apache.pekko.http.scaladsl.settings.ServerSettings.enableHttp2") diff --git a/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/PreviewServerSettings.scala b/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/PreviewServerSettings.scala index 44de8d4c3..c3c148c3a 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/PreviewServerSettings.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/PreviewServerSettings.scala @@ -26,11 +26,11 @@ import com.typesafe.config.Config * These options may change and/or be removed within patch releases * without early notice (e.g. by moving them into a stable supported place). * - * @deprecated PreviewServerSettings is deprecated, use pekko.http.javadsl.settings.ServerSettings instead (since 2.0.0) + * @deprecated PreviewServerSettings is deprecated, use pekko.http.javadsl.settings.ServerSettings instead (since 1.3.0) */ @ApiMayChange @DoNotInherit @Deprecated -@deprecated("PreviewServerSettings is deprecated, use pekko.http.javadsl.settings.ServerSettings instead", "2.0.0") +@deprecated("PreviewServerSettings is deprecated, use pekko.http.javadsl.settings.ServerSettings instead", "1.3.0") abstract class PreviewServerSettings private[pekko] () { self: PreviewServerSettingsImpl => /** diff --git a/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSettings.scala b/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSettings.scala index 36a23b7b2..51f3df32c 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSettings.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSettings.scala @@ -34,7 +34,7 @@ import scala.concurrent.duration.{ Duration, FiniteDuration } */ @DoNotInherit abstract class ServerSettings { self: ServerSettingsImpl => def getServerHeader: Optional[Server] - @deprecated("the preview server settings are now integrated into the main server settings", "2.0.0") + @deprecated("the preview server settings are now integrated into the main server settings", "1.3.0") def getPreviewServerSettings: PreviewServerSettings def getTimeouts: ServerSettings.Timeouts def getMaxConnections: Int @@ -67,7 +67,7 @@ import scala.concurrent.duration.{ Duration, FiniteDuration } def withServerHeader(newValue: Optional[Server]): ServerSettings = self.copy(serverHeader = newValue.toScala.map(_.asScala)) - @deprecated("the preview server settings are now integrated into the main server settings", "2.0.0") + @deprecated("the preview server settings are now integrated into the main server settings", "1.3.0") def withPreviewServerSettings(newValue: PreviewServerSettings): ServerSettings = self.copy(previewServerSettings = newValue.asScala) def withTimeouts(newValue: ServerSettings.Timeouts): ServerSettings = self.copy(timeouts = newValue.asScala) diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/PreviewServerSettings.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/PreviewServerSettings.scala index 5c513538f..9de8d7beb 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/PreviewServerSettings.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/PreviewServerSettings.scala @@ -25,10 +25,10 @@ import com.typesafe.config.Config * These options may change and/or be removed within patch releases * without early notice (e.g. by moving them into a stable supported place). * - * @deprecated PreviewServerSettings is deprecated, use pekko.http.scaladsl.settings.ServerSettings instead (since 2.0.0) + * @deprecated PreviewServerSettings is deprecated, use pekko.http.scaladsl.settings.ServerSettings instead (since 1.3.0) */ @ApiMayChange @DoNotInherit -@deprecated("PreviewServerSettings is deprecated, use pekko.http.scaladsl.settings.ServerSettings instead", "2.0.0") +@deprecated("PreviewServerSettings is deprecated, use pekko.http.scaladsl.settings.ServerSettings instead", "1.3.0") abstract class PreviewServerSettings private[pekko] () extends org.apache.pekko.http.javadsl.settings.PreviewServerSettings { self: PreviewServerSettingsImpl => diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ServerSettings.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ServerSettings.scala index cf8f717ca..520035f09 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ServerSettings.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ServerSettings.scala @@ -62,7 +62,7 @@ abstract class ServerSettings private[pekko] () extends pekko.http.javadsl.setti def streamCancellationDelay: FiniteDuration /** - * @since 2.0.0 + * @since 1.3.0 */ def enableHttp2: Boolean @@ -71,10 +71,10 @@ abstract class ServerSettings private[pekko] () extends pekko.http.javadsl.setti override def getBacklog = this.backlog /** - * @deprecated the preview server settings are now integrated into the main server settings (since 2.0.0) + * @deprecated the preview server settings are now integrated into the main server settings (since 1.3.0) */ @Deprecated - @deprecated("the preview server settings are now integrated into the main server settings", "2.0.0") + @deprecated("the preview server settings are now integrated into the main server settings", "1.3.0") override def getPreviewServerSettings: pekko.http.javadsl.settings.PreviewServerSettings = this.previewServerSettings override def getDefaultHostHeader = this.defaultHostHeader.asJava override def getPipeliningLimit = this.pipeliningLimit @@ -99,10 +99,10 @@ abstract class ServerSettings private[pekko] () extends pekko.http.javadsl.setti // override for more specific return type /** - * @deprecated the preview server settings are now integrated into the main server settings (since 2.0.0) + * @deprecated the preview server settings are now integrated into the main server settings (since 1.3.0) */ @Deprecated - @deprecated("the preview server settings are now integrated into the main server settings", "2.0.0") + @deprecated("the preview server settings are now integrated into the main server settings", "1.3.0") def withPreviewServerSettings(newValue: PreviewServerSettings): ServerSettings = self.copy(previewServerSettings = newValue) override def withMaxConnections(newValue: Int): ServerSettings = self.copy(maxConnections = newValue) From 49100b6cca9dcc91eb36f1f910681ca5e97765d8 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Fri, 3 Oct 2025 07:06:19 +0100 Subject: [PATCH 4/5] scaladoc --- .../apache/pekko/http/javadsl/settings/ServerSettings.scala | 6 ++++++ .../pekko/http/scaladsl/settings/ServerSettings.scala | 3 +++ 2 files changed, 9 insertions(+) diff --git a/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSettings.scala b/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSettings.scala index 51f3df32c..1f9dcc1db 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSettings.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSettings.scala @@ -60,6 +60,8 @@ import scala.concurrent.duration.{ Duration, FiniteDuration } /** * Configures the Http extension to bind using HTTP/2 if given an * [[pekko.http.scaladsl.HttpsConnectionContext]]. Otherwise binds as plain HTTP. + * + * @since 1.3.0 */ def enableHttp2: Boolean @@ -95,6 +97,10 @@ import scala.concurrent.duration.{ Duration, FiniteDuration } def withParsingErrorHandler(newValue: String): ServerSettings = self.copy(parsingErrorHandler = parsingErrorHandler) def withStreamCancellationDelay(newValue: FiniteDuration): ServerSettings = self.copy(streamCancellationDelay = newValue) + + /** + * @since 1.3.0 + */ def withEnableHttp2(newValue: Boolean): ServerSettings = self.copy(enableHttp2 = newValue) } diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ServerSettings.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ServerSettings.scala index 520035f09..79599fa86 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ServerSettings.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ServerSettings.scala @@ -62,6 +62,9 @@ abstract class ServerSettings private[pekko] () extends pekko.http.javadsl.setti def streamCancellationDelay: FiniteDuration /** + * Configures the Http extension to bind using HTTP/2 if given an + * [[pekko.http.scaladsl.HttpsConnectionContext]]. Otherwise binds as plain HTTP. + * * @since 1.3.0 */ def enableHttp2: Boolean From acdf7ee146b0d59209d3084f01083556a7539997 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Fri, 3 Oct 2025 10:27:41 +0100 Subject: [PATCH 5/5] Update ServerSettingsSpec.scala --- .../settings/ServerSettingsSpec.scala | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) 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 20197cb52..9c1b72a63 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 @@ -13,6 +13,7 @@ package org.apache.pekko.http.scaladsl.settings +import com.typesafe.config.ConfigFactory import org.apache.pekko.testkit.PekkoSpec class ServerSettingsSpec extends PekkoSpec { @@ -32,5 +33,37 @@ class ServerSettingsSpec extends PekkoSpec { } e.getMessage should include("does not contain the server-specific settings") } + "default enableHttp2 to false" in { + val serverSettings = ServerSettings(system) + serverSettings.enableHttp2 should ===(false) + } + "set enableHttp2 to true if preview.enable-http2 is on" in { + val cfg = ConfigFactory.parseString(""" + pekko.http.server { + preview.enable-http2 = on + } + """).withFallback(system.settings.config) + val serverSettings = ServerSettings(cfg) + serverSettings.enableHttp2 should ===(true) + } + "set enableHttp2 to true if enable-http2 is on" in { + val cfg = ConfigFactory.parseString(""" + pekko.http.server { + enable-http2 = on + } + """).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 { + 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) + } } }