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 a9101db1f remove getRemoteAddressHeader (#757)
a9101db1f is described below
commit a9101db1feebbacf8b6811511e629f55e4bd4481
Author: PJ Fanning <[email protected]>
AuthorDate: Thu Sep 11 14:52:56 2025 +0100
remove getRemoteAddressHeader (#757)
* remove getRemoteAddressHeader
* try to remove remoteAddressAttribute altogether
* more work on removing remote-address-header
* Update Http2ServerSpec.scala
* Update remove-deprecated-methods.excludes
---
.../directives/misc-directives/extractClientIP.md | 3 +-
.../remove-deprecated-methods.excludes | 5 +++
http-core/src/main/resources/reference.conf | 8 +---
.../pekko/http/impl/engine/http2/Http2.scala | 1 -
.../http/impl/engine/http2/RequestParsing.scala | 10 +----
.../impl/engine/server/HttpServerBluePrint.scala | 9 +---
.../http/impl/settings/ServerSettingsImpl.scala | 2 -
.../scala/org/apache/pekko/http/javadsl/Http.scala | 6 +--
.../http/javadsl/settings/ServerSettings.scala | 8 ----
.../org/apache/pekko/http/scaladsl/Http.scala | 7 +---
.../http/scaladsl/settings/ServerSettings.scala | 4 --
.../http/impl/engine/server/HttpServerSpec.scala | 29 +------------
.../pekko/http/scaladsl/ClientServerSpec.scala | 49 +---------------------
.../settings/PreviewServerSettingsSpec.scala | 1 -
.../impl/engine/http2/Http2ClientServerSpec.scala | 3 +-
.../http/impl/engine/http2/Http2ClientSpec.scala | 1 -
.../impl/engine/http2/Http2ServerDemuxSpec.scala | 1 -
.../Http2ServerDisableFrameTypeThrottleSpec.scala | 1 -
.../Http2ServerEnableFrameTypeThrottleSpec.scala | 1 -
.../http/impl/engine/http2/Http2ServerSpec.scala | 21 ----------
20 files changed, 16 insertions(+), 154 deletions(-)
diff --git
a/docs/src/main/paradox/routing-dsl/directives/misc-directives/extractClientIP.md
b/docs/src/main/paradox/routing-dsl/directives/misc-directives/extractClientIP.md
index 9ab5a26b3..2832a417a 100644
---
a/docs/src/main/paradox/routing-dsl/directives/misc-directives/extractClientIP.md
+++
b/docs/src/main/paradox/routing-dsl/directives/misc-directives/extractClientIP.md
@@ -11,8 +11,7 @@
## Description
Provides the value of the `X-Forwarded-For` or `X-Real-IP` header.
-If neither of those is found it will fall back to the value of the synthetic
`RemoteAddress` header (`pekko.http.server.remote-address-header` setting is
`on`)
-or the value of the @apidoc[AttributeKeys.remoteAddress](AttributeKeys$)
@ref[attribute](../../../common/http-model.md#attributes) (if the
`pekko.http.server.remote-address-attribute` setting is `on`)
+If neither of those is found it will fall back to the value of the value of
the @apidoc[AttributeKeys.remoteAddress](AttributeKeys$)
@ref[attribute](../../../common/http-model.md#attributes) (if the
`pekko.http.server.remote-address-attribute` setting is `on`)
If no valid IP address is encountered, this extractor will return
RemoteAddress.Unknown`.
diff --git
a/http-core/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes
b/http-core/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes
index 8b8e85c60..a562dd925 100644
---
a/http-core/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes
+++
b/http-core/src/main/mima-filters/2.0.x.backwards.excludes/remove-deprecated-methods.excludes
@@ -48,6 +48,8 @@
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javads
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.model.headers.HttpCookie.create")
ProblemFilters.exclude[IncompatibleMethTypeProblem]("org.apache.pekko.http.javadsl.model.headers.HttpChallenge.create")
ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.http.javadsl.model.ws.UpgradeToWebSocket")
+ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.settings.ServerSettings.getRemoteAddressHeader")
+ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.settings.ServerSettings.withRemoteAddressHeader")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.settings.ServerSettings.getWebsocketRandomFactory")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.settings.ServerSettings.withWebsocketRandomFactory")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.ConnectionContext.https")
@@ -108,6 +110,9 @@
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scalad
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.model.headers.HttpCookie.this")
ProblemFilters.exclude[MissingClassProblem]("org.apache.pekko.http.scaladsl.model.ws.UpgradeToWebSocket")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.settings.ConnectionPoolSettings.transport")
+ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.settings.ServerSettings.remoteAddressHeader")
+ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.settings.ServerSettings.getRemoteAddressHeader")
+ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.settings.ServerSettings.withRemoteAddressHeader")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.settings.ServerSettings.websocketRandomFactory")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.settings.ServerSettings.getWebsocketRandomFactory")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.settings.ServerSettings.withWebsocketRandomFactory")
diff --git a/http-core/src/main/resources/reference.conf
b/http-core/src/main/resources/reference.conf
index ec2c1b7d6..fae5ac0b1 100644
--- a/http-core/src/main/resources/reference.conf
+++ b/http-core/src/main/resources/reference.conf
@@ -98,14 +98,8 @@ pekko.http {
# This value must be > 0 and <= 1024.
pipelining-limit = 1
- # Enables/disables the addition of a `Remote-Address` header
- # holding the clients (remote) IP address.
- # Deprecated since Akka HTTP 10.2.0: please use `remote-address-attribute`
instead.
- remote-address-header = off
-
# Enables/disables the addition of a remote-address attribute in
HttpRequest
- # holding the clients (remote) IP address. This is preferred over
`remote-address-header`
- # because it cannot be confused with a real header.
+ # holding the clients (remote) IP address.
remote-address-attribute = off
# Enables/disables the addition of a `Raw-Request-URI` header holding the
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2.scala
b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2.scala
index bd98c428f..0aa371ef8 100644
---
a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2.scala
+++
b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2.scala
@@ -50,7 +50,6 @@ import pekko.util.ByteString
import pekko.Done
import javax.net.ssl.SSLEngine
-import scala.annotation.nowarn
import scala.collection.immutable
import scala.concurrent.Future
import scala.concurrent.duration.Duration
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/RequestParsing.scala
b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/RequestParsing.scala
index 75a206cad..3542ce121 100644
---
a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/RequestParsing.scala
+++
b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/RequestParsing.scala
@@ -21,7 +21,7 @@ import pekko.http.impl.engine.parsing.HttpHeaderParser
import pekko.http.impl.engine.server.HttpAttributes
import pekko.http.scaladsl.model
import pekko.http.scaladsl.model._
-import pekko.http.scaladsl.model.headers.{ `Remote-Address`,
`Tls-Session-Info` }
+import pekko.http.scaladsl.model.headers.`Tls-Session-Info`
import pekko.http.scaladsl.settings.ServerSettings
import pekko.stream.Attributes
import pekko.util.ByteString
@@ -41,13 +41,6 @@ private[http2] object RequestParsing {
def parseRequest(httpHeaderParser: HttpHeaderParser, serverSettings:
ServerSettings, streamAttributes: Attributes)
: Http2SubStream => HttpRequest = {
- val remoteAddressHeader: Option[`Remote-Address`] =
- if (serverSettings.remoteAddressHeader) {
- streamAttributes.get[HttpAttributes.RemoteAddress].map(remote =>
- model.headers.`Remote-Address`(RemoteAddress(remote.address)))
- // in order to avoid searching all the time for the attribute, we need
to guard it with the setting condition
- } else None // no need to emit the remote address header
-
val remoteAddressAttribute: Option[RemoteAddress] =
if (serverSettings.remoteAddressAttribute) {
streamAttributes.get[HttpAttributes.RemoteAddress].map(remote =>
RemoteAddress(remote.address))
@@ -97,7 +90,6 @@ private[http2] object RequestParsing {
// Compress 'cookie' headers if present
headers += parseHeaderPair(httpHeaderParser, "cookie",
cookies.toString)
}
- if (remoteAddressHeader.isDefined) headers += remoteAddressHeader.get
if (tlsSessionInfoHeader.isDefined) headers += tlsSessionInfoHeader.get
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/server/HttpServerBluePrint.scala
b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/server/HttpServerBluePrint.scala
index c745fc86e..e4e23fb68 100644
---
a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/server/HttpServerBluePrint.scala
+++
b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/server/HttpServerBluePrint.scala
@@ -49,7 +49,6 @@ import pekko.http.javadsl.model
import pekko.http.scaladsl.model._
import pekko.http.impl.util.LogByteStringTools._
-import scala.annotation.nowarn
import scala.util.Failure
/**
@@ -159,14 +158,8 @@ private[http] object HttpServerBluePrint {
val effectiveMethod = if (method == HttpMethods.HEAD &&
settings.transparentHeadRequests) HttpMethods.GET
else method
- @nowarn("msg=use remote-address-attribute instead")
- val effectiveHeaders =
- if (settings.remoteAddressHeader && remoteAddressOpt.isDefined)
- headers.`Remote-Address`(RemoteAddress(remoteAddressOpt.get))
+: hdrs
- else hdrs
-
val entity =
createEntity(entityCreator).withSizeLimit(settings.parserSettings.maxContentLength)
- val httpRequest = HttpRequest(effectiveMethod, uri,
effectiveHeaders, entity, protocol)
+ val httpRequest = HttpRequest(effectiveMethod, uri, hdrs, entity,
protocol)
.withAttributes(attrs)
val effectiveHttpRequest = if (settings.remoteAddressAttribute) {
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 ab05102f0..273645f53 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
@@ -40,7 +40,6 @@ private[pekko] final case class ServerSettingsImpl(
timeouts: ServerSettings.Timeouts,
maxConnections: Int,
pipeliningLimit: Int,
- remoteAddressHeader: Boolean,
remoteAddressAttribute: Boolean,
rawRequestUriHeader: Boolean,
transparentHeadRequests: Boolean,
@@ -102,7 +101,6 @@ private[http] object ServerSettingsImpl extends
SettingsCompanionImpl[ServerSett
c.getPotentiallyInfiniteDuration("linger-timeout")),
c.getInt("max-connections"),
c.getInt("pipelining-limit"),
- c.getBoolean("remote-address-header"),
c.getBoolean("remote-address-attribute"),
c.getBoolean("raw-request-uri-header"),
c.getBoolean("transparent-head-requests"),
diff --git a/http-core/src/main/scala/org/apache/pekko/http/javadsl/Http.scala
b/http-core/src/main/scala/org/apache/pekko/http/javadsl/Http.scala
index 0af829131..44629bd36 100644
--- a/http-core/src/main/scala/org/apache/pekko/http/javadsl/Http.scala
+++ b/http-core/src/main/scala/org/apache/pekko/http/javadsl/Http.scala
@@ -72,8 +72,7 @@ class Http(system: ExtendedActorSystem) extends
pekko.actor.Extension {
/**
* Constructs a server layer stage using the given
[[pekko.http.javadsl.settings.ServerSettings]]. The returned
[[pekko.stream.javadsl.BidiFlow]] isn't reusable and
- * can only be materialized once. The `remoteAddress`, if provided, will be
added as a header to each [[HttpRequest]]
- * this layer produces if the `pekko.http.server.remote-address-header`
configuration option is enabled.
+ * can only be materialized once.
*/
def serverLayer(
settings: ServerSettings,
@@ -83,8 +82,7 @@ class Http(system: ExtendedActorSystem) extends
pekko.actor.Extension {
/**
* Constructs a server layer stage using the given [[ServerSettings]]. The
returned [[pekko.stream.javadsl.BidiFlow]] isn't reusable and
- * can only be materialized once. The remoteAddress, if provided, will be
added as a header to each [[HttpRequest]]
- * this layer produces if the `pekko.http.server.remote-address-header`
configuration option is enabled.
+ * can only be materialized once.
*/
def serverLayer(
settings: ServerSettings,
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 8c8be7c46..c1a48dfa2 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
@@ -38,13 +38,6 @@ import scala.concurrent.duration.{ Duration, FiniteDuration }
def getTimeouts: ServerSettings.Timeouts
def getMaxConnections: Int
def getPipeliningLimit: Int
-
- /**
- * @deprecated since Akka HTTP 10.2.0, use remoteAddressAttribute instead
- */
- @Deprecated
- @deprecated("Use remoteAddressAttribute instead", since = "Akka HTTP 10.2.0")
- def getRemoteAddressHeader: Boolean
def getRemoteAddressAttribute: Boolean
def getRawRequestUriHeader: Boolean
def getTransparentHeadRequests: Boolean
@@ -72,7 +65,6 @@ import scala.concurrent.duration.{ Duration, FiniteDuration }
def withTimeouts(newValue: ServerSettings.Timeouts): ServerSettings =
self.copy(timeouts = newValue.asScala)
def withMaxConnections(newValue: Int): ServerSettings =
self.copy(maxConnections = newValue)
def withPipeliningLimit(newValue: Int): ServerSettings =
self.copy(pipeliningLimit = newValue)
- def withRemoteAddressHeader(newValue: Boolean): ServerSettings =
self.copy(remoteAddressHeader = newValue)
def withRemoteAddressAttribute(newValue: Boolean): ServerSettings =
self.copy(remoteAddressAttribute = newValue)
def withRawRequestUriHeader(newValue: Boolean): ServerSettings =
self.copy(rawRequestUriHeader = newValue)
def withTransparentHeadRequests(newValue: Boolean): ServerSettings =
self.copy(transparentHeadRequests = newValue)
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 cd3893064..72ea4b428 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
@@ -48,7 +48,6 @@ import pekko.util.ByteString
import pekko.util.FutureConverters._
import pekko.util.ManifestInfo
-import scala.annotation.nowarn
import scala.concurrent._
import scala.concurrent.duration._
import scala.util.{ Success, Try }
@@ -309,8 +308,7 @@ class HttpExt @InternalStableApi /* constructor signature
is hardcoded in Teleme
/**
* Constructs a [[pekko.http.scaladsl.Http.ServerLayer]] stage using the
given [[pekko.http.scaladsl.settings.ServerSettings]]. The returned
[[pekko.stream.scaladsl.BidiFlow]] isn't reusable and
- * can only be materialized once. The `remoteAddress`, if provided, will be
added as a header to each [[pekko.http.scaladsl.model.HttpRequest]]
- * this layer produces if the `pekko.http.server.remote-address-header`
configuration option is enabled.
+ * can only be materialized once.
*/
def serverLayer(
settings: ServerSettings = ServerSettings(system),
@@ -1052,10 +1050,9 @@ object Http extends ExtensionId[HttpExt] with
ExtensionIdProvider {
def createExtension(system: ExtendedActorSystem): HttpExt =
new HttpExt(system.settings.config.getConfig("pekko.http"))(system)
- @nowarn("msg=use remote-address-attribute instead")
@InternalApi
private[pekko] def prepareAttributes(settings: ServerSettings, incoming:
Tcp.IncomingConnection) =
- if (settings.remoteAddressHeader || settings.remoteAddressAttribute)
+ if (settings.remoteAddressAttribute)
HttpAttributes.remoteAddress(incoming.remoteAddress)
else HttpAttributes.empty
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 0b533ec64..d95f734f6 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
@@ -43,8 +43,6 @@ abstract class ServerSettings private[pekko] () extends
pekko.http.javadsl.setti
def timeouts: ServerSettings.Timeouts
def maxConnections: Int
def pipeliningLimit: Int
- @deprecated("use remote-address-attribute instead", since = "Akka HTTP
10.2.0")
- def remoteAddressHeader: Boolean
def remoteAddressAttribute: Boolean
def rawRequestUriHeader: Boolean
def transparentHeadRequests: Boolean
@@ -78,7 +76,6 @@ abstract class ServerSettings private[pekko] () extends
pekko.http.javadsl.setti
override def getServerHeader = this.serverHeader.map(_.asJava).toJava
override def getTimeouts = this.timeouts
override def getRawRequestUriHeader = this.rawRequestUriHeader
- override def getRemoteAddressHeader = this.remoteAddressHeader
override def getRemoteAddressAttribute: Boolean = this.remoteAddressAttribute
override def getLogUnencryptedNetworkBytes =
this.logUnencryptedNetworkBytes.toJava
override def getDefaultHttpPort: Int = this.defaultHttpPort
@@ -94,7 +91,6 @@ abstract class ServerSettings private[pekko] () extends
pekko.http.javadsl.setti
self.copy(previewServerSettings = newValue)
override def withMaxConnections(newValue: Int): ServerSettings =
self.copy(maxConnections = newValue)
override def withPipeliningLimit(newValue: Int): ServerSettings =
self.copy(pipeliningLimit = newValue)
- override def withRemoteAddressHeader(newValue: Boolean): ServerSettings =
self.copy(remoteAddressHeader = newValue)
override def withRemoteAddressAttribute(newValue: Boolean): ServerSettings =
self.copy(remoteAddressAttribute = newValue)
override def withRawRequestUriHeader(newValue: Boolean): ServerSettings =
self.copy(rawRequestUriHeader = newValue)
diff --git
a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/server/HttpServerSpec.scala
b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/server/HttpServerSpec.scala
index 893973e8d..ea30afcf0 100644
---
a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/server/HttpServerSpec.scala
+++
b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/server/HttpServerSpec.scala
@@ -37,7 +37,7 @@ import pekko.util.ByteString
import org.scalatest.Inside
import java.net.{ InetAddress, InetSocketAddress }
-import scala.annotation.{ nowarn, tailrec }
+import scala.annotation.tailrec
import scala.concurrent.duration._
import scala.reflect.ClassTag
import scala.util.Random
@@ -1164,33 +1164,6 @@ class HttpServerSpec extends PekkoSpec(
netOut.expectComplete()
})
- "support remote-address-header when blueprint not constructed with it" in
assertAllStagesStopped(new TestSetup {
- // coverage for #21130
- lazy val theAddress = InetAddress.getByName("127.5.2.1")
-
- override def settings: ServerSettings =
- super.settings.withRemoteAddressHeader(true)
-
- // this is the normal behavior for bindAndHandle(flow), it will set an
attribute
- // with remote ip before flow is materialized, rather than from the
blueprint apply method
- override def modifyServer(server: ServerLayer): ServerLayer = {
- BidiFlow.fromGraph(server.withAttributes(
- HttpAttributes.remoteAddress(new InetSocketAddress(theAddress,
8080))))
- }
-
- send("""GET / HTTP/1.1
- |Host: example.com
- |
- |""".stripMarginWithNewline("\r\n"))
-
- val request = expectRequest()
-
- request.headers should
contain(`Remote-Address`(RemoteAddress(theAddress, Some(8080)))): @nowarn(
- "msg=Remote-Address in package headers is deprecated")
-
- shutdownBlueprint()
- })
-
"support remote-address-attribute" in assertAllStagesStopped(new TestSetup
{
lazy val theAddress = InetAddress.getByName("127.5.2.1")
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 b4a4cff6c..9f8649d46 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
@@ -20,7 +20,7 @@ import java.util.concurrent.TimeoutException
import java.util.concurrent.atomic.AtomicLong
import javax.net.ssl.{ SNIMatcher, SNIServerName, SSLContext, SSLEngine,
TrustManagerFactory }
-import scala.annotation.{ nowarn, tailrec }
+import scala.annotation.tailrec
import scala.concurrent.duration._
import scala.concurrent.{ Await, Future, Promise }
import scala.util.{ Success, Try }
@@ -192,53 +192,6 @@ abstract class ClientServerSpecBase(http2: Boolean)
extends PekkoSpecWithMateria
Await.result(b1.unbind(), 1.second.dilated)
}
- // The Remote-Address header is deprecated, but we still want to test it
works
- "Remote-Address header" should {
- def handler(req: HttpRequest): HttpResponse = {
- @nowarn("msg=deprecated")
- val entity =
req.header[headers.`Remote-Address`].flatMap(_.address.toIP).flatMap(_.port).toString
- HttpResponse(entity = entity)
- }
-
- "be added when using bind API" in new RemoteAddressTestScenario {
- def createBinding(): Future[ServerBinding] =
- Http().newServerAt("localhost",
0).withSettings(settings).connectionSource()
- .map(_.flow.join(Flow[HttpRequest].map(handler)).run())
- .to(Sink.ignore)
- .run()
- }
-
- "be added when using bindFlow API" in new RemoteAddressTestScenario {
- def createBinding(): Future[ServerBinding] =
- Http().newServerAt("localhost",
0).withSettings(settings).bindFlow(Flow[HttpRequest].map(handler))
- }
-
- "be added when using bindSync API" in new RemoteAddressTestScenario {
- def createBinding(): Future[ServerBinding] =
- Http().newServerAt("localhost",
0).withSettings(settings).bindSync(handler)
- }
-
- abstract class RemoteAddressTestScenario {
- val settings = ServerSettings(system).withRemoteAddressHeader(true)
- def createBinding(): Future[ServerBinding]
-
- val binding = createBinding()
- val b1 = Await.result(binding, 3.seconds.dilated)
-
- val (conn, response) =
- Source.single(HttpRequest(uri = "/abc"))
- .viaMat(Http().outgoingConnection("localhost",
b1.localAddress.getPort))(Keep.right)
- .toMat(Sink.head)(Keep.both)
- .run()
-
- val r = Await.result(response, 1.second.dilated)
- val c = Await.result(conn, 1.second.dilated)
- Await.result(b1.unbind(), 1.second.dilated)
-
- toStrict(r.entity).data.utf8String shouldBe
s"Some(${c.localAddress.getPort})"
- }
- }
-
"timeouts" should {
def bindServer(hostname: String, port: Int, serverIdleTimeout:
FiniteDuration): (Promise[Long], ServerBinding) = {
val s = ServerSettings(system)
diff --git
a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/PreviewServerSettingsSpec.scala
b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/PreviewServerSettingsSpec.scala
index d3494d350..f63326941 100644
---
a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/PreviewServerSettingsSpec.scala
+++
b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/PreviewServerSettingsSpec.scala
@@ -23,7 +23,6 @@ class PreviewServerSettingsSpec extends PekkoSpec {
"compile when set programmatically" in compileOnlySpec {
ServerSettings(system)
.withPreviewServerSettings(PreviewServerSettings(system).withEnableHttp2(true))
- .withRemoteAddressHeader(true)
}
"work get right defaults" in {
val it: PreviewServerSettings = PreviewServerSettings(system)
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 3679a19c0..d2d7b30ea 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
@@ -49,8 +49,7 @@ import scala.concurrent.duration._
import scala.concurrent.{ Future, Promise }
class Http2ClientServerSpec extends PekkoSpecWithMaterializer(
- """pekko.http.server.remote-address-header = on
- pekko.http.server.http2.log-frames = on
+ """pekko.http.server.http2.log-frames = on
pekko.http.server.log-unencrypted-network-bytes = 100
pekko.http.server.preview.enable-http2 = on
pekko.http.client.http2.log-frames = on
diff --git
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ClientSpec.scala
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ClientSpec.scala
index 6220625a0..11e9e90b4 100644
---
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ClientSpec.scala
+++
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ClientSpec.scala
@@ -73,7 +73,6 @@ import scala.collection.immutable
* * validate the produced application-level responses
*/
class Http2ClientSpec extends PekkoSpecWithMaterializer("""
- pekko.http.client.remote-address-header = on
pekko.http.client.http2.log-frames = on
pekko.http.client.http2.completion-timeout = 500ms
""")
diff --git
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ServerDemuxSpec.scala
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ServerDemuxSpec.scala
index 3de6d3c0a..05d0db3a4 100644
---
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ServerDemuxSpec.scala
+++
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ServerDemuxSpec.scala
@@ -28,7 +28,6 @@ import scala.collection.immutable.Seq
* low-level tests testing Http2ServerDemux in isolation
*/
class Http2ServerDemuxSpec extends PekkoSpecWithMaterializer("""
- pekko.http.server.remote-address-header = on
pekko.http.server.http2.log-frames = on
pekko.stream.materializer.debug.fuzzing-mode = on
""") {
diff --git
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ServerDisableFrameTypeThrottleSpec.scala
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ServerDisableFrameTypeThrottleSpec.scala
index 1d8de5240..2b82e2659 100644
---
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ServerDisableFrameTypeThrottleSpec.scala
+++
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ServerDisableFrameTypeThrottleSpec.scala
@@ -24,7 +24,6 @@ import java.nio.ByteOrder
* This tests the http2 server throttle support for rapid resets is disabled
by default.
*/
class Http2ServerDisableFrameTypeThrottleSpec extends
Http2SpecWithMaterializer("""
- pekko.http.server.remote-address-header = on
pekko.http.server.http2.log-frames = on
""") {
override def failOnSevereMessages: Boolean = true
diff --git
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ServerEnableFrameTypeThrottleSpec.scala
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ServerEnableFrameTypeThrottleSpec.scala
index 2ff5a9d08..75b426662 100644
---
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ServerEnableFrameTypeThrottleSpec.scala
+++
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ServerEnableFrameTypeThrottleSpec.scala
@@ -24,7 +24,6 @@ import java.nio.ByteOrder
* This tests the http2 server throttle support for rapid resets.
*/
class Http2ServerEnableFrameTypeThrottleSpec extends
Http2SpecWithMaterializer("""
- pekko.http.server.remote-address-header = on
pekko.http.server.http2.log-frames = on
pekko.http.server.http2.frame-type-throttle.frame-types = ["reset"]
""") {
diff --git
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ServerSpec.scala
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ServerSpec.scala
index cd3f459be..9afdc6524 100644
---
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ServerSpec.scala
+++
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2ServerSpec.scala
@@ -52,7 +52,6 @@ import scala.concurrent.{ Await, Promise }
* * validate the produced response frames
*/
class Http2ServerSpec extends Http2SpecWithMaterializer("""
- pekko.http.server.remote-address-header = on
pekko.http.server.http2.log-frames = on
""")
with Eventually {
@@ -1540,26 +1539,6 @@ class Http2ServerSpec extends
Http2SpecWithMaterializer("""
}
"expose synthetic headers" should {
- "expose Remote-Address".inAssertAllStagesStopped(new TestSetup with
RequestResponseProbes {
-
- lazy val theAddress = "127.0.0.1"
- lazy val thePort = 1337
- override def modifyServer(
- server: BidiFlow[HttpResponse, ByteString, ByteString,
HttpRequest, ServerTerminator]) =
- BidiFlow.fromGraph(server.withAttributes(
- HttpAttributes.remoteAddress(new InetSocketAddress(theAddress,
thePort))))
-
- val target = Uri("http://www.example.com/")
- network.sendRequest(1, HttpRequest(uri = target))
- user.requestIn.ensureSubscription()
-
- val request = user.expectRequestRaw()
- @nowarn("msg=deprecated")
- val remoteAddressHeader = request.header[headers.`Remote-Address`].get
- remoteAddressHeader.address.getAddress.get().toString shouldBe ("/" +
theAddress)
- remoteAddressHeader.address.getPort shouldBe thePort
- })
-
"expose Tls-Session-Info".inAssertAllStagesStopped(new TestSetup with
RequestResponseProbes {
override def settings: ServerSettings =
super.settings.withParserSettings(super.settings.parserSettings.withIncludeTlsSessionInfoHeader(true))
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]