diff --git a/docs/src/main/paradox/common/marshalling.md b/docs/src/main/paradox/common/marshalling.md index 250111c971..ef77ce347c 100644 --- a/docs/src/main/paradox/common/marshalling.md +++ b/docs/src/main/paradox/common/marshalling.md @@ -70,13 +70,13 @@ Specifically these are: * @apidoc[StatusCode] * `(StatusCode, T)`, if a `ToEntityMarshaller[T]` is available * `(Int, T)`, if a `ToEntityMarshaller[T]` is available - * `(StatusCode, immutable.Seq[HttpHeader], T)`, if a `ToEntityMarshaller[T]` is available - * `(Int, immutable.Seq[HttpHeader], T)`, if a `ToEntityMarshaller[T]` is available + * `(StatusCode, Seq[HttpHeader], T)`, if a `ToEntityMarshaller[T]` is available + * `(Int, Seq[HttpHeader], T)`, if a `ToEntityMarshaller[T]` is available * @scaladoc[PredefinedToRequestMarshallers](org.apache.pekko.http.scaladsl.marshalling.PredefinedToRequestMarshallers) * @apidoc[HttpRequest] * @apidoc[Uri] * `(HttpMethod, Uri, T)`, if a `ToEntityMarshaller[T]` is available - * `(HttpMethod, Uri, immutable.Seq[HttpHeader], T)`, if a `ToEntityMarshaller[T]` is available + * `(HttpMethod, Uri, Seq[HttpHeader], T)`, if a `ToEntityMarshaller[T]` is available * @scaladoc[GenericMarshallers](org.apache.pekko.http.scaladsl.marshalling.GenericMarshallers) * @apidoc[Marshaller[Throwable, T]] * @apidoc[Marshaller[Option[A], B]], if a @apidoc[Marshaller[A, B]] and an `EmptyValue[B]` is available diff --git a/docs/src/main/paradox/routing-dsl/directives/alphabetically.md b/docs/src/main/paradox/routing-dsl/directives/alphabetically.md index 7bcb5896be..bac54197dc 100644 --- a/docs/src/main/paradox/routing-dsl/directives/alphabetically.md +++ b/docs/src/main/paradox/routing-dsl/directives/alphabetically.md @@ -84,12 +84,12 @@ |@ref[logRequestResult](debugging-directives/logRequestResult.md) | Produces a log entry for every incoming request and @apidoc[RouteResult] | |@ref[logResult](debugging-directives/logResult.md) | Produces a log entry for every @apidoc[RouteResult] | |@ref[mapInnerRoute](basic-directives/mapInnerRoute.md) | Transforms its inner @scala[@scaladoc[Route](org.apache.pekko.http.scaladsl.server.index#Route=org.apache.pekko.http.scaladsl.server.RequestContext=%3Escala.concurrent.Future[org.apache.pekko.http.scaladsl.server.RouteResult])]@java[@javadoc[Route](org.apache.pekko.http.javadsl.server.Route)] with a @scala[`Route => Route`]@java[`UnaryOperator`] function | -|@ref[mapRejections](basic-directives/mapRejections.md) | Transforms rejections from a previous route with an @scala[`immutable.Seq[Rejection] => immutable.Seq[Rejection]`]@java[`UnaryOperator>`] function | +|@ref[mapRejections](basic-directives/mapRejections.md) | Transforms rejections from a previous route with an @scala[`Seq[Rejection] => Seq[Rejection]`]@java[`UnaryOperator>`] function | |@ref[mapRequest](basic-directives/mapRequest.md) | Transforms the request with an @scala[`HttpRequest => HttpRequest`]@java[`UnaryOperator`] function | |@ref[mapRequestContext](basic-directives/mapRequestContext.md) | Transforms the @apidoc[RequestContext] with a @scala[`RequestContext => RequestContext`]@java[`UnaryOperator`] function | |@ref[mapResponse](basic-directives/mapResponse.md) | Transforms the response with an @scala[`HttpResponse => HttpResponse`]@java[`UnaryOperator`] function | |@ref[mapResponseEntity](basic-directives/mapResponseEntity.md) | Transforms the response entity with an @scala[`ResponseEntity => ResponseEntity`]@java[`UnaryOperator`] function | -|@ref[mapResponseHeaders](basic-directives/mapResponseHeaders.md) | Transforms the response headers with an @scala[`immutable.Seq[HttpHeader] => immutable.Seq[HttpHeader]`]@java[`UnaryOperator>`] function | +|@ref[mapResponseHeaders](basic-directives/mapResponseHeaders.md) | Transforms the response headers with an @scala[`Seq[HttpHeader] => Seq[HttpHeader]`]@java[`UnaryOperator>`] function | |@ref[mapRouteResult](basic-directives/mapRouteResult.md) | Transforms the @apidoc[RouteResult] with a @scala[`RouteResult => RouteResult`]@java[`UnaryOperator`] function | |@ref[mapRouteResultFuture](basic-directives/mapRouteResultFuture.md) | Transforms the @apidoc[RouteResult] future with a @scala[`Future[RouteResult] => Future[RouteResult]`]@java[`UnaryOperator>`] function | |@ref[mapRouteResultPF](basic-directives/mapRouteResultPF.md) | Transforms the @apidoc[RouteResult] with a @scala[`PartialFunction[RouteResult, RouteResult]`]@java[`PartialFunction`] | @@ -130,8 +130,8 @@ |@ref[query](method-directives/query.md) | Rejects all non-QUERY requests | |@ref[rawPathPrefix](path-directives/rawPathPrefix.md) | Applies the given matcher directly to a prefix of the unmatched path of the @apidoc[RequestContext], without implicitly consuming a leading slash | |@ref[rawPathPrefixTest](path-directives/rawPathPrefixTest.md) | Checks whether the unmatchedPath has a prefix matched by the given `PathMatcher` | -|@ref[recoverRejections](basic-directives/recoverRejections.md) | Transforms rejections from the inner route with an @scala[`immutable.Seq[Rejection] => RouteResult`]@java[`Function, RouteResult>`] function | -|@ref[recoverRejectionsWith](basic-directives/recoverRejectionsWith.md) | Transforms rejections from the inner route with an @scala[`immutable.Seq[Rejection] => Future[RouteResult]`]@java[`Function>`] function | +|@ref[recoverRejections](basic-directives/recoverRejections.md) | Transforms rejections from the inner route with an @scala[`Seq[Rejection] => RouteResult`]@java[`Function, RouteResult>`] function | +|@ref[recoverRejectionsWith](basic-directives/recoverRejectionsWith.md) | Transforms rejections from the inner route with an @scala[`Seq[Rejection] => Future[RouteResult]`]@java[`Function>`] function | |@ref[redirect](route-directives/redirect.md) | Completes the request with redirection response of the given type to the given URI | |@ref[redirectToNoTrailingSlashIfPresent](path-directives/redirectToNoTrailingSlashIfPresent.md) | If the request path ends with a slash, redirects to the same URI without trailing slash in the path | |@ref[redirectToTrailingSlashIfMissing](path-directives/redirectToTrailingSlashIfMissing.md) | If the request path doesn't end with a slash, redirects to the same URI with trailing slash in the path | diff --git a/docs/src/main/paradox/routing-dsl/directives/basic-directives/recoverRejections.md b/docs/src/main/paradox/routing-dsl/directives/basic-directives/recoverRejections.md index 1a2d252325..924766e05e 100644 --- a/docs/src/main/paradox/routing-dsl/directives/basic-directives/recoverRejections.md +++ b/docs/src/main/paradox/routing-dsl/directives/basic-directives/recoverRejections.md @@ -14,7 +14,7 @@ want to try the @ref[handleRejections](../execution-directives/handleRejections.md) directive which provides a nicer DSL for building rejection handlers. Transforms rejections from the inner route with -@scala[an `immutable.Seq[Rejection] => RouteResult` function.] +@scala[an `Seq[Rejection] => RouteResult` function.] @java[a `Function, RouteResult>`.] A @apidoc[RouteResult] is either a @scala[`Complete(HttpResponse(...))`] diff --git a/docs/src/main/paradox/routing-dsl/directives/basic-directives/recoverRejectionsWith.md b/docs/src/main/paradox/routing-dsl/directives/basic-directives/recoverRejectionsWith.md index d244e38e4c..a2a2d2d447 100644 --- a/docs/src/main/paradox/routing-dsl/directives/basic-directives/recoverRejectionsWith.md +++ b/docs/src/main/paradox/routing-dsl/directives/basic-directives/recoverRejectionsWith.md @@ -13,7 +13,7 @@ **Low level directive** – unless you're sure you need to be working on this low-level you might instead want to try the @ref[handleRejections](../execution-directives/handleRejections.md) directive which provides a nicer DSL for building rejection handlers. -Transforms rejections from the inner route with @scala[an `immutable.Seq[Rejection] => Future[RouteResult]` function]@java[a `Function, CompletionStage>`]. +Transforms rejections from the inner route with @scala[an `Seq[Rejection] => Future[RouteResult]` function]@java[a `Function, CompletionStage>`]. Asynchronous version of @ref[recoverRejections](recoverRejections.md). diff --git a/docs/src/main/paradox/routing-dsl/rejections.md b/docs/src/main/paradox/routing-dsl/rejections.md index 73cf38d5c7..8b865cd030 100644 --- a/docs/src/main/paradox/routing-dsl/rejections.md +++ b/docs/src/main/paradox/routing-dsl/rejections.md @@ -104,7 +104,7 @@ you can attach handling logic for certain types of rejections through three help run when the rejection is "caught". This makes the full power of the Routing DSL available for defining rejection handlers and even allows for recursing back into the main route structure if required. -@scala[handleAll[T <: Rejection: ClassTag](f: immutable.Seq[T] => Route)]@java[handleAll(Class, Function, Route>)] +@scala[handleAll[T <: Rejection: ClassTag](f: Seq[T] => Route)]@java[handleAll(Class, Function, Route>)] : Handles all rejections of a certain type at the same time. This is useful for cases where your need access to more than the first rejection of a certain type, e.g. for producing the error message to an unsupported request method. diff --git a/docs/src/main/paradox/routing-dsl/routes.md b/docs/src/main/paradox/routing-dsl/routes.md index cbe83066e5..15c1df66ed 100644 --- a/docs/src/main/paradox/routing-dsl/routes.md +++ b/docs/src/main/paradox/routing-dsl/routes.md @@ -69,7 +69,7 @@ sealed trait RouteResult object RouteResult { final case class Complete(response: HttpResponse) extends RouteResult - final case class Rejected(rejections: immutable.Seq[Rejection]) extends RouteResult + final case class Rejected(rejections: Seq[Rejection]) extends RouteResult } ``` diff --git a/docs/src/test/scala/docs/http/scaladsl/HttpRequestDetailedStringExampleSpec.scala b/docs/src/test/scala/docs/http/scaladsl/HttpRequestDetailedStringExampleSpec.scala index 4d78929e1f..bbb03026c0 100644 --- a/docs/src/test/scala/docs/http/scaladsl/HttpRequestDetailedStringExampleSpec.scala +++ b/docs/src/test/scala/docs/http/scaladsl/HttpRequestDetailedStringExampleSpec.scala @@ -18,8 +18,6 @@ import pekko.http.scaladsl.model.{ HttpEntity, HttpRequest } import pekko.http.scaladsl.model.headers.{ Authorization, BasicHttpCredentials } import pekko.testkit.PekkoSpec -import scala.collection.immutable - class HttpRequestDetailedStringExampleSpec extends PekkoSpec { // Custom string representation which includes headers @@ -38,7 +36,7 @@ class HttpRequestDetailedStringExampleSpec extends PekkoSpec { "This body contains information about [user]" val httpRequestWithHeadersAndBody = - HttpRequest(entity = piiBody, headers = immutable.Seq(piiHeader)) + HttpRequest(entity = piiBody, headers = Seq(piiHeader)) // Our custom string representation includes body and headers string representations... assert( diff --git a/docs/src/test/scala/docs/http/scaladsl/HttpResponseDetailedStringExampleSpec.scala b/docs/src/test/scala/docs/http/scaladsl/HttpResponseDetailedStringExampleSpec.scala index ee58fddecf..ce3ce3fd21 100644 --- a/docs/src/test/scala/docs/http/scaladsl/HttpResponseDetailedStringExampleSpec.scala +++ b/docs/src/test/scala/docs/http/scaladsl/HttpResponseDetailedStringExampleSpec.scala @@ -18,8 +18,6 @@ import pekko.http.scaladsl.model.{ HttpEntity, HttpResponse } import pekko.http.scaladsl.model.headers.{ Authorization, BasicHttpCredentials } import pekko.testkit.PekkoSpec -import scala.collection.immutable - class HttpResponseDetailedStringExampleSpec extends PekkoSpec { // Custom string representation which includes headers @@ -38,7 +36,7 @@ class HttpResponseDetailedStringExampleSpec extends PekkoSpec { "This body contains information about [user]" val httpResponseWithHeadersAndBody = - HttpResponse(entity = piiBody, headers = immutable.Seq(piiHeader)) + HttpResponse(entity = piiBody, headers = Seq(piiHeader)) // Our custom string representation includes body and headers string representations... assert( diff --git a/docs/src/test/scala/docs/http/scaladsl/WebSocketClientExampleSpec.scala b/docs/src/test/scala/docs/http/scaladsl/WebSocketClientExampleSpec.scala index bef111c20a..15568c7541 100644 --- a/docs/src/test/scala/docs/http/scaladsl/WebSocketClientExampleSpec.scala +++ b/docs/src/test/scala/docs/http/scaladsl/WebSocketClientExampleSpec.scala @@ -112,7 +112,6 @@ class WebSocketClientExampleSpec extends AnyWordSpec with Matchers with CompileO import pekko.http.scaladsl.model.ws._ implicit val system = ActorSystem() - import collection.immutable.Seq val flow: Flow[Message, Message, NotUsed] = Flow.fromSinkAndSource( diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/FrameEvent.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/FrameEvent.scala index 9888ee0ea6..718ca6cff0 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/FrameEvent.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/FrameEvent.scala @@ -21,8 +21,6 @@ import pekko.http.impl.engine.http2.Http2Protocol.SettingIdentifier import pekko.http.scaladsl.model.ErrorInfo import pekko.util.ByteString -import scala.collection.immutable - /** INTERNAL API */ @InternalApi private[http2] sealed trait FrameEvent { self: Product => @@ -78,8 +76,8 @@ private[http] object FrameEvent { headerBlockFragment: ByteString) extends StreamFrameEvent final case class RstStreamFrame(streamId: Int, errorCode: ErrorCode) extends StreamFrameEvent - final case class SettingsFrame(settings: immutable.Seq[Setting]) extends FrameEvent - final case class SettingsAckFrame(acked: immutable.Seq[Setting]) extends FrameEvent + final case class SettingsFrame(settings: Seq[Setting]) extends FrameEvent + final case class SettingsAckFrame(acked: Seq[Setting]) extends FrameEvent case class PingFrame(ack: Boolean, data: ByteString) extends FrameEvent { require(data.size == 8, s"PingFrame payload must be of size 8 but was ${data.size}") diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/FrameLogger.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/FrameLogger.scala index 00caa04853..6a041f2f17 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/FrameLogger.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/FrameLogger.scala @@ -19,7 +19,6 @@ import pekko.annotation.InternalApi import pekko.stream.scaladsl.{ BidiFlow, Flow } import pekko.util.ByteString -import scala.collection.immutable.Seq import FrameEvent._ import pekko.event.Logging import pekko.stream.Attributes 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 74025c4f44..4c86c3bcc3 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 @@ -49,7 +49,6 @@ import pekko.util.ByteString import pekko.Done import javax.net.ssl.SSLEngine -import scala.collection.immutable import scala.concurrent.{ ExecutionContext, Future } import scala.concurrent.duration.Duration import scala.util.control.NonFatal @@ -199,7 +198,7 @@ private[http] final class Http2Ext(implicit val system: ActorSystem) upgradeSettings match { // Must be exactly one - case immutable.Seq(Success(settingsFromHeader)) => + case Seq(Success(settingsFromHeader)) => // inject the actual upgrade request with a stream identifier of 1 // https://http2.github.io/http2-spec/#rfc.section.3.2 val injectedRequest = Source.single(req.addAttribute(Http2.streamId, 1)) @@ -217,11 +216,11 @@ private[http] final class Http2Ext(implicit val system: ActorSystem) Future.successful( HttpResponse( StatusCodes.SwitchingProtocols, - immutable.Seq[HttpHeader]( + Seq[HttpHeader]( ConnectionUpgradeHeader, UpgradeHeader, UpgradeToOtherProtocolResponseHeader(serverLayer)))) - case immutable.Seq(Failure(e)) => + case Seq(Failure(e)) => log.warning("Failed to parse http2-settings header in upgrade [{}], continuing with HTTP/1.1", e.getMessage) handler(req) // A server MUST NOT upgrade the connection to HTTP/2 if this header field diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2Blueprint.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2Blueprint.scala index 33794e00ca..aff6e14ae3 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2Blueprint.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2Blueprint.scala @@ -43,7 +43,6 @@ import pekko.util.Helpers.toRootLowerCase import scala.concurrent.duration.{ Duration, FiniteDuration } import scala.concurrent.{ ExecutionContext, Future } -import scala.collection.immutable import scala.util.control.NonFatal /** @@ -130,7 +129,7 @@ private[http] object Http2Blueprint { def serverStack( settings: ServerSettings, log: LoggingAdapter, - initialDemuxerSettings: immutable.Seq[Setting] = Nil, + initialDemuxerSettings: Seq[Setting] = Nil, upgraded: Boolean = false, telemetry: TelemetrySpi, dateHeaderRendering: DateHeaderRendering): BidiFlow[HttpResponse, ByteString, ByteString, HttpRequest, ServerTerminator] = { @@ -272,7 +271,7 @@ private[http] object Http2Blueprint { * Creates substreams for every stream and manages stream state machines * and handles priorization (TODO: later) */ - def serverDemux(settings: Http2ServerSettings, initialDemuxerSettings: immutable.Seq[Setting], upgraded: Boolean) + def serverDemux(settings: Http2ServerSettings, initialDemuxerSettings: Seq[Setting], upgraded: Boolean) : BidiFlow[Http2SubStream, FrameEvent, FrameEvent, Http2SubStream, ServerTerminator] = BidiFlow.fromGraph(new Http2ServerDemux(settings, initialDemuxerSettings, upgraded)) diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2Demux.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2Demux.scala index 56c0369e7b..35ff328cce 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2Demux.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2Demux.scala @@ -44,7 +44,6 @@ import pekko.stream.stage.{ import pekko.util.ByteString import pekko.util.OptionVal -import scala.collection.immutable import scala.concurrent.{ ExecutionContext, Future, Promise } import scala.concurrent.duration.Duration import scala.concurrent.duration.DurationInt @@ -74,7 +73,7 @@ private[http2] class Http2ClientDemux(http2Settings: Http2ClientSettings, master * INTERNAL API */ @InternalApi -private[http2] class Http2ServerDemux(http2Settings: Http2ServerSettings, initialRemoteSettings: immutable.Seq[Setting], +private[http2] class Http2ServerDemux(http2Settings: Http2ServerSettings, initialRemoteSettings: Seq[Setting], upgraded: Boolean) extends Http2Demux(http2Settings, initialRemoteSettings, upgraded, isServer = true) { // We don't provide access to incoming trailing request headers on the server side @@ -216,7 +215,7 @@ private[http2] object ConfigurablePing { */ @InternalApi private[http2] abstract class Http2Demux(http2Settings: Http2CommonSettings, - initialRemoteSettings: immutable.Seq[Setting], upgraded: Boolean, isServer: Boolean) + initialRemoteSettings: Seq[Setting], upgraded: Boolean, isServer: Boolean) extends GraphStageWithMaterializedValue[BidiShape[Http2SubStream, FrameEvent, FrameEvent, Http2SubStream], ServerTerminator] { stage => @@ -295,10 +294,10 @@ private[http2] abstract class Http2Demux(http2Settings: Http2CommonSettings, // Send initial settings based on the local application.conf. For simplicity, these settings are // enforced immediately even before the acknowledgement is received. // Reminder: the receiver of a SETTINGS frame must process them in the order they are received. - val initialLocalSettings: immutable.Seq[Setting] = immutable.Seq( + val initialLocalSettings: Seq[Setting] = Seq( Setting(SettingIdentifier.SETTINGS_MAX_CONCURRENT_STREAMS, http2Settings.maxConcurrentStreams), Setting(SettingIdentifier.SETTINGS_MAX_HEADER_LIST_SIZE, http2Settings.maxHeaderListSize)) ++ - immutable.Seq(Setting(SettingIdentifier.SETTINGS_ENABLE_PUSH, 0)).filter(_ => !isServer) // only on client + Seq(Setting(SettingIdentifier.SETTINGS_ENABLE_PUSH, 0)).filter(_ => !isServer) // only on client override def preStart(): Unit = { if (initialRemoteSettings.nonEmpty) { @@ -485,7 +484,7 @@ private[http2] abstract class Http2Demux(http2Settings: Http2CommonSettings, * was raised. When raising an ERROR, this method already pushes the * error back to the peer. */ - private def applyRemoteSettings(settings: immutable.Seq[Setting]): Boolean = { + private def applyRemoteSettings(settings: Seq[Setting]): Boolean = { var settingsAppliedOk = true settings.foreach { diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2SettingsHeader.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2SettingsHeader.scala index 4d76466c40..0bed784dc7 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2SettingsHeader.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2SettingsHeader.scala @@ -23,7 +23,6 @@ import pekko.http.impl.engine.http2.FrameEvent.Setting import pekko.stream.impl.io import pekko.util.ByteString -import scala.collection.immutable import scala.util.Try /** @@ -41,7 +40,7 @@ private[pekko] object Http2SettingsHeader { def headerValueToBinary(value: String): ByteString = ByteString(base64UrlStringDecoder(value.toCharArray)) - def parse(value: String, log: LoggingAdapter): Try[immutable.Seq[Setting]] = Try { + def parse(value: String, log: LoggingAdapter): Try[Seq[Setting]] = Try { // settings are a base64url encoded Http2 settings frame // https://httpwg.org/specs/rfc7540.html#rfc.section.3.2.1 val bytes = headerValueToBinary(value) diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/HttpMessageRendering.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/HttpMessageRendering.scala index c70f1d0db1..b9242a2afc 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/HttpMessageRendering.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/HttpMessageRendering.scala @@ -148,7 +148,7 @@ private[http2] object HttpMessageRendering { } def renderHeaders( - headers: immutable.Seq[HttpHeader], + headers: Seq[HttpHeader], log: LoggingAdapter, isServer: Boolean, shouldRenderAutoHeaders: Boolean, @@ -164,7 +164,7 @@ private[http2] object HttpMessageRendering { * peer. For example, a User-Agent on the client or a Server header on the server. */ def renderHeaders( - headersSeq: immutable.Seq[HttpHeader], + headersSeq: Seq[HttpHeader], headerPairs: VectorBuilder[(String, String)], peerIdHeader: Option[(String, String)], log: LoggingAdapter, diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/PriorityTree.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/PriorityTree.scala index 0f6999b62a..9a1ce12b88 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/PriorityTree.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/PriorityTree.scala @@ -26,7 +26,7 @@ private[http2] trait PriorityNode { def streamId: Int def weight: Int def dependency: PriorityNode - def children: immutable.Seq[PriorityNode] + def children: Seq[PriorityNode] } /** INTERNAL API */ @@ -154,7 +154,7 @@ private[http2] object PriorityTree { def streamId: Int = _streamId def weight: Int = nodes(streamId).weight def dependency: PriorityNode = node(nodes(streamId).streamDependency) - def children: immutable.Seq[PriorityNode] = nodes(streamId).childrenIds.toVector.map(node) + def children: Seq[PriorityNode] = nodes(streamId).childrenIds.toVector.map(node) } } diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/framing/Http2FrameParsing.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/framing/Http2FrameParsing.scala index bc263f3488..d236e06c7e 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/framing/Http2FrameParsing.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/framing/Http2FrameParsing.scala @@ -14,7 +14,6 @@ package org.apache.pekko.http.impl.engine.http2 package framing -import scala.collection.immutable import org.apache.pekko import pekko.event.LoggingAdapter import pekko.stream.Attributes @@ -33,8 +32,8 @@ import scala.annotation.tailrec @InternalApi private[http] object Http2FrameParsing { - def readSettings(payload: ByteStringParser.ByteReader, log: LoggingAdapter): immutable.Seq[Setting] = { - @tailrec def readSettings(read: List[Setting]): immutable.Seq[Setting] = + def readSettings(payload: ByteStringParser.ByteReader, log: LoggingAdapter): Seq[Setting] = { + @tailrec def readSettings(read: List[Setting]): Seq[Setting] = if (payload.hasRemaining) { val id = payload.readShortBE() val value = payload.readIntBE() diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/hpack/HeaderCompression.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/hpack/HeaderCompression.scala index 52254b9e92..9bce63b8ed 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/hpack/HeaderCompression.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/hpack/HeaderCompression.scala @@ -22,7 +22,6 @@ import pekko.stream.{ Attributes, FlowShape, Inlet, Outlet } import pekko.stream.stage.{ GraphStage, GraphStageLogic, InHandler, OutHandler, StageLogging } import pekko.util.ByteString -import scala.collection.immutable import FrameEvent._ /** @@ -100,7 +99,7 @@ private[http2] object HeaderCompression extends GraphStage[FlowShape[FrameEvent, case x => push(eventsOut, x) } - def applySettings(s: immutable.Seq[Setting]): Unit = + def applySettings(s: Seq[Setting]): Unit = s.foreach { case Setting(SettingIdentifier.SETTINGS_HEADER_TABLE_SIZE, size) => log.debug("Applied SETTINGS_HEADER_TABLE_SIZE({}) in header compression", size) diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/rendering/BodyPartRenderer.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/rendering/BodyPartRenderer.scala index d36b1bf496..3558288283 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/rendering/BodyPartRenderer.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/rendering/BodyPartRenderer.scala @@ -16,7 +16,6 @@ package org.apache.pekko.http.impl.engine.rendering import org.apache.pekko import org.parboiled2.util.Base64 -import scala.collection.immutable import pekko.event.LoggingAdapter import pekko.http.scaladsl.model._ import pekko.http.scaladsl.model.HttpEntity._ @@ -102,7 +101,7 @@ private[http] object BodyPartRenderer { } - def strict(parts: immutable.Seq[Multipart.BodyPart.Strict], boundary: String, + def strict(parts: Seq[Multipart.BodyPart.Strict], boundary: String, partHeadersSizeHint: Int, log: LoggingAdapter): ByteString = { val r = new ByteStringRendering(partHeadersSizeHint) if (parts.nonEmpty) { @@ -125,7 +124,7 @@ private[http] object BodyPartRenderer { private def renderFinalBoundary(r: Rendering, boundary: String): Unit = r ~~ CrLf ~~ '-' ~~ '-' ~~ boundary ~~ '-' ~~ '-' - private def renderHeaders(r: Rendering, headers: immutable.Seq[HttpHeader], log: LoggingAdapter): Unit = { + private def renderHeaders(r: Rendering, headers: Seq[HttpHeader], log: LoggingAdapter): Unit = { headers.foreach(renderHeader(r, log)) r ~~ CrLf } diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/rendering/HttpResponseRendererFactory.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/rendering/HttpResponseRendererFactory.scala index 3e6d6bec2c..1374ac1623 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/rendering/HttpResponseRendererFactory.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/rendering/HttpResponseRendererFactory.scala @@ -14,7 +14,6 @@ package org.apache.pekko.http.impl.engine.rendering import scala.annotation.tailrec -import scala.collection.immutable import scala.util.control.NonFatal import org.apache.pekko @@ -164,7 +163,7 @@ private[http] class HttpResponseRendererFactory( entity.isChunked && (!entity.isKnownEmpty || ctx.requestMethod == HttpMethods.HEAD) && (ctx.requestProtocol == `HTTP/1.1`) - def renderHeaders(headers: immutable.Seq[HttpHeader], alwaysClose: Boolean = false): Unit = { + def renderHeaders(headers: Seq[HttpHeader], alwaysClose: Boolean = false): Unit = { var connHeader: Connection = null var serverSeen: Boolean = false var transferEncodingSeen: Boolean = false diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/Handshake.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/Handshake.scala index 77a2096fe1..1ee6eb1991 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/Handshake.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/Handshake.scala @@ -18,8 +18,6 @@ import java.util.Random import org.apache.pekko import pekko.annotation.InternalApi -import scala.collection.immutable -import scala.collection.immutable.Seq import pekko.event.LoggingAdapter import pekko.http.impl.util._ import pekko.http.impl.engine.server.UpgradeToOtherProtocolResponseHeader @@ -270,7 +268,7 @@ private[http] object Handshake { /** * Builds a WebSocket handshake request. */ - def buildRequest(uri: Uri, extraHeaders: immutable.Seq[HttpHeader], subprotocols: Seq[String], random: Random) + def buildRequest(uri: Uri, extraHeaders: Seq[HttpHeader], subprotocols: Seq[String], random: Random) : (HttpRequest, `Sec-WebSocket-Key`) = { val keyBytes = new Array[Byte](16) random.nextBytes(keyBytes) diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/PerMessageDeflate.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/PerMessageDeflate.scala index ad5141fab2..8453fcc2cf 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/PerMessageDeflate.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/PerMessageDeflate.scala @@ -134,7 +134,7 @@ private[http] object PerMessageDeflate { rsv1IndicatesCompression = false))) def negotiate( - requested: immutable.Seq[WebSocketExtension], + requested: Seq[WebSocketExtension], settings: WebSocketCompressionSettingsImpl): Option[Negotiated] = { if (!settings.enabled) None else { diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/WebSocketClientBlueprint.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/WebSocketClientBlueprint.scala index 34b4e97d6b..aeecc4d541 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/WebSocketClientBlueprint.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/ws/WebSocketClientBlueprint.scala @@ -38,8 +38,6 @@ import pekko.http.impl.util.LogByteStringTools import pekko.http.impl.util.{ SingletonException, StreamUtils } import pekko.stream.impl.fusing.GraphStages.SimpleLinearGraphStage -import scala.collection.immutable - /** INTERNAL API */ @InternalApi private[http] object WebSocketClientBlueprint { @@ -72,7 +70,7 @@ private[http] object WebSocketClientBlueprint { val valve = StreamUtils.OneTimeValve() - val subprotocols: immutable.Seq[String] = subprotocol.toList.flatMap(_.split(",")).map(_.trim) + val subprotocols: Seq[String] = subprotocol.toList.flatMap(_.split(",")).map(_.trim) val (initialRequest, key) = Handshake.Client.buildRequest(uri, extraHeaders, subprotocols, settings.websocketRandomFactory()) val hostHeader = Host(uri.authority.normalizedFor(uri.scheme)) diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/CommonRules.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/CommonRules.scala index 6b4b7df60f..2ea1f4a774 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/CommonRules.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/CommonRules.scala @@ -359,7 +359,7 @@ private[parser] trait CommonRules extends StringBuilding { this: Parser => // http://tools.ietf.org/html/rfc6454#section-7.1 // ****************************************************************************************** def `origin-list-or-null` = rule { - "null" ~ OWS ~ push(immutable.Seq.empty[HttpOrigin]) | `origin-list` + "null" ~ OWS ~ push(Seq.empty[HttpOrigin]) | `origin-list` } def `origin-list` = rule { diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/LinkHeader.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/LinkHeader.scala index fbd95a7127..78c2ae585b 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/LinkHeader.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/model/parser/LinkHeader.scala @@ -80,10 +80,10 @@ private[parser] trait LinkHeader { this: Parser with CommonRules with CommonActi rule { `media-type` ~> ((mt, st, pm) => getMediaType(mt, st, pm contains "charset", TreeMap(pm: _*))) } // filter out subsequent `rel`, `media`, `title`, `type` and `type*` params - @tailrec private def sanitize(params: Seq[LinkParam], result: immutable.Seq[LinkParam] = Nil, + @tailrec private def sanitize(params: Seq[LinkParam], result: Seq[LinkParam] = Nil, seenRel: Boolean = false, seenMedia: Boolean = false, seenTitle: Boolean = false, seenTitleS: Boolean = false, - seenType: Boolean = false): immutable.Seq[LinkParam] = + seenType: Boolean = false): Seq[LinkParam] = params match { case Seq(x: LinkParams.rel, tail @ _*) => sanitize(tail, if (seenRel) result else result :+ x, seenRel = true, seenMedia, seenTitle, seenTitleS, seenType) diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/settings/ClientConnectionSettingsImpl.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/settings/ClientConnectionSettingsImpl.scala index 9da508eac8..c5b13e8d8a 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/settings/ClientConnectionSettingsImpl.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/settings/ClientConnectionSettingsImpl.scala @@ -27,7 +27,6 @@ import pekko.http.scaladsl.settings.{ Http2ClientSettings, ParserSettings, WebSo import pekko.io.Inet.SocketOption import com.typesafe.config.Config -import scala.collection.immutable import scala.concurrent.duration.{ Duration, FiniteDuration } import scala.jdk.DurationConverters._ import scala.util.Try @@ -41,7 +40,7 @@ private[pekko] final case class ClientConnectionSettingsImpl( requestHeaderSizeHint: Int, logUnencryptedNetworkBytes: Option[Int], websocketSettings: WebSocketSettings, - socketOptions: immutable.Seq[SocketOption], + socketOptions: Seq[SocketOption], parserSettings: ParserSettings, streamCancellationDelay: FiniteDuration, localAddress: Option[InetSocketAddress], diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/settings/ConnectionPoolSettingsImpl.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/settings/ConnectionPoolSettingsImpl.scala index 02a18db6d0..f0dbf40d1b 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/settings/ConnectionPoolSettingsImpl.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/settings/ConnectionPoolSettingsImpl.scala @@ -19,7 +19,6 @@ import pekko.http.impl.util._ import pekko.http.scaladsl.settings._ import com.typesafe.config.Config -import scala.collection.immutable import scala.concurrent.duration.Duration import scala.concurrent.duration.FiniteDuration import scala.jdk.DurationConverters._ @@ -40,7 +39,7 @@ private[pekko] final case class ConnectionPoolSettingsImpl( keepAliveTimeout: Duration, connectionSettings: ClientConnectionSettings, responseEntitySubscriptionTimeout: Duration, - hostOverrides: immutable.Seq[(Regex, ConnectionPoolSettings)]) + hostOverrides: Seq[(Regex, ConnectionPoolSettings)]) extends ConnectionPoolSettings { require(maxConnections > 0, "max-connections must be > 0") 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 74e8ac317e..75ef0086a2 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 @@ -13,7 +13,6 @@ package org.apache.pekko.http.impl.settings -import scala.collection.immutable import scala.concurrent.duration._ import scala.util.Try @@ -45,7 +44,7 @@ private[pekko] final case class ServerSettingsImpl( responseHeaderSizeHint: Int, backlog: Int, logUnencryptedNetworkBytes: Option[Int], - socketOptions: immutable.Seq[SocketOption], + socketOptions: Seq[SocketOption], defaultHostHeader: Host, websocketSettings: WebSocketSettings, parserSettings: ParserSettings, diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/util/JavaMapping.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/util/JavaMapping.scala index c3851aac50..4c99f95365 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/util/JavaMapping.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/util/JavaMapping.scala @@ -55,9 +55,9 @@ private[http] object J2SMapping { implicit def fromJavaMapping[J](implicit mapping: JavaMapping[J, ?]): J2SMapping[J] { type S = mapping.S } = mapping implicit def fromJavaSeqMapping[J]( - implicit mapping: J2SMapping[J]): J2SMapping[Seq[J]] { type S = immutable.Seq[mapping.S] } = + implicit mapping: J2SMapping[J]): J2SMapping[Seq[J]] { type S = Seq[mapping.S] } = new J2SMapping[Seq[J]] { - type S = immutable.Seq[mapping.S] + type S = Seq[mapping.S] def toScala(javaObject: Seq[J]): S = javaObject.map(mapping.toScala(_)).toList } } @@ -98,7 +98,7 @@ private[http] object JavaMapping { object Implicits { implicit def convertToScala[J](j: J)(implicit mapping: J2SMapping[J]): mapping.S = mapping.toScala(j) - implicit def convertSeqToScala[J](j: Seq[J])(implicit mapping: J2SMapping[J]): immutable.Seq[mapping.S] = + implicit def convertSeqToScala[J](j: Seq[J])(implicit mapping: J2SMapping[J]): Seq[mapping.S] = j.map(mapping.toScala(_)).toList implicit def AddAsScala[J](javaObject: J)(implicit mapping: J2SMapping[J]): AsScala[mapping.S] = @@ -119,12 +119,12 @@ private[http] object JavaMapping { } implicit def iterableMapping[_J, _S]( - implicit mapping: JavaMapping[_J, _S]): JavaMapping[jl.Iterable[_J], immutable.Seq[_S]] = - new JavaMapping[jl.Iterable[_J], immutable.Seq[_S]] { + implicit mapping: JavaMapping[_J, _S]): JavaMapping[jl.Iterable[_J], Seq[_S]] = + new JavaMapping[jl.Iterable[_J], Seq[_S]] { import scala.jdk.CollectionConverters._ - def toJava(scalaObject: immutable.Seq[_S]): jl.Iterable[_J] = scalaObject.map(mapping.toJava).asJavaCollection - def toScala(javaObject: jl.Iterable[_J]): immutable.Seq[_S] = + def toJava(scalaObject: Seq[_S]): jl.Iterable[_J] = scalaObject.map(mapping.toJava).asJavaCollection + def toScala(javaObject: jl.Iterable[_J]): Seq[_S] = Implicits.convertSeqToScala(javaObject.asScala.toSeq) } implicit def map[K, V]: JavaMapping[ju.Map[K, V], immutable.Map[K, V]] = diff --git a/http-core/src/main/scala/org/apache/pekko/http/impl/util/SocketOptionSettings.scala b/http-core/src/main/scala/org/apache/pekko/http/impl/util/SocketOptionSettings.scala index adb31d5de8..b5a22b6a8a 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/impl/util/SocketOptionSettings.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/impl/util/SocketOptionSettings.scala @@ -16,13 +16,11 @@ package org.apache.pekko.http.impl.util import org.apache.pekko import pekko.io.{ Inet, Tcp } -import scala.collection.immutable - import pekko.io.Inet.SocketOption import com.typesafe.config.Config private[http] object SocketOptionSettings { - def fromSubConfig(root: Config, c: Config): immutable.Seq[SocketOption] = { + def fromSubConfig(root: Config, c: Config): Seq[SocketOption] = { def so[T](setting: String)(f: (Config, String) => T)(cons: T => SocketOption): List[SocketOption] = c.getString(setting) match { case "undefined" => Nil diff --git a/http-core/src/main/scala/org/apache/pekko/http/javadsl/model/Trailer.scala b/http-core/src/main/scala/org/apache/pekko/http/javadsl/model/Trailer.scala index 93936e3a57..cf58d0387e 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/javadsl/model/Trailer.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/javadsl/model/Trailer.scala @@ -15,8 +15,6 @@ package org.apache.pekko.http.javadsl.model import org.apache.pekko.http.scaladsl.{ model => sm } -import scala.collection.immutable - /** Trailing headers for HTTP/2 responses */ trait Trailer { @@ -36,5 +34,5 @@ trait Trailer { def withHeaders(headers: Iterable[HttpHeader]): Trailer } object Trailer { - def create(): Trailer = new sm.Trailer(immutable.Seq.empty) + def create(): Trailer = new sm.Trailer(Seq.empty) } diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpCharset.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpCharset.scala index d6f4904cce..dba362bf2b 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpCharset.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpCharset.scala @@ -14,7 +14,6 @@ package org.apache.pekko.http.scaladsl.model import java.lang.{ Iterable => JIterable } -import scala.collection.immutable import scala.util.Try import java.nio.charset.Charset import org.apache.pekko @@ -58,7 +57,7 @@ object HttpCharsetRange { def apply(charset: HttpCharset, qValue: Float): HttpCharsetRange = One(charset, qValue) } -final case class HttpCharset private[http] (override val value: String)(val aliases: immutable.Seq[String]) +final case class HttpCharset private[http] (override val value: String)(val aliases: Seq[String]) extends jm.HttpCharset with SingletonValueRenderable with WithQValue[HttpCharsetRange] { @transient private var _nioCharset: Try[Charset] = HttpCharset.findNioCharset(value) @@ -95,7 +94,7 @@ final case class HttpCharset private[http] (override val value: String)(val alia object HttpCharset { def custom(value: String, aliases: String*): HttpCharset = - HttpCharset(value)(immutable.Seq(aliases: _*)) + HttpCharset(value)(Seq(aliases: _*)) private[http] def findNioCharset(name: String): Try[Charset] = Try(Charset.forName(name)) } @@ -109,7 +108,7 @@ object HttpCharsets extends ObjectRegistry[String, HttpCharset] { /** Register standard charset that is required to be supported on all platforms */ private def register(value: String)(aliases: String*): HttpCharset = - register(HttpCharset(value)(immutable.Seq(aliases: _*))) + register(HttpCharset(value)(Seq(aliases: _*))) /** Register non-standard charsets that may be missing on some platforms */ private def tryRegister(value: String)(aliases: String*): Unit = diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpEntity.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpEntity.scala index 6034c57de2..435cdedf28 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpEntity.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpEntity.scala @@ -22,7 +22,6 @@ import java.util.concurrent.CompletionStage import scala.annotation.nowarn import scala.concurrent.Future import scala.concurrent.duration._ -import scala.collection.immutable import scala.jdk.FutureConverters._ import scala.jdk.OptionConverters._ import scala.util.control.NonFatal @@ -618,7 +617,7 @@ object HttpEntity { * by directly using the `LastChunk` companion object. */ case class LastChunk( - extension: String = "", trailer: immutable.Seq[HttpHeader] = Nil) extends HttpEntity.ChunkStreamPart { + extension: String = "", trailer: Seq[HttpHeader] = Nil) extends HttpEntity.ChunkStreamPart { def data = ByteString.empty def isLastChunk = true diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpHeader.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpHeader.scala index f5aa9eb82d..c8e352568c 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpHeader.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpHeader.scala @@ -25,8 +25,6 @@ import pekko.http.scaladsl.model.headers._ import pekko.util.OptionVal import pekko.util.Helpers.toRootLowerCase -import scala.collection.immutable - /** * Marker trait for headers which contain portentially secret / sensitive information. * @@ -111,7 +109,7 @@ object HttpHeader { /** INTERNAL API */ @InternalApi private[pekko] def fastFind[T >: Null <: jm.HttpHeader]( - clazz: Class[T], headers: immutable.Seq[HttpHeader]): OptionVal[T] = { + clazz: Class[T], headers: Seq[HttpHeader]): OptionVal[T] = { val it = headers.iterator while (it.hasNext) it.next() match { case h if clazz.isInstance(h) => return OptionVal.Some[T](h.asInstanceOf[T]) diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpMessage.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpMessage.scala index bb769021a5..b1963843c6 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpMessage.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpMessage.scala @@ -20,7 +20,6 @@ import java.util.Optional import java.util.concurrent.{ CompletionStage, Executor } import scala.annotation.tailrec -import scala.collection.immutable import scala.concurrent.{ ExecutionContext, Future } import scala.concurrent.duration._ import scala.jdk.FutureConverters._ @@ -48,7 +47,7 @@ sealed trait HttpMessage extends jm.HttpMessage { def isRequest: Boolean def isResponse: Boolean - def headers: immutable.Seq[HttpHeader] + def headers: Seq[HttpHeader] def attributes: Map[AttributeKey[?], ?] def entity: ResponseEntity def protocol: HttpProtocol @@ -84,7 +83,7 @@ sealed trait HttpMessage extends jm.HttpMessage { withHeaders(firstHeader +: otherHeaders.toList) /** Returns a copy of this message with the list of headers set to the given ones. */ - def withHeaders(headers: immutable.Seq[HttpHeader]): Self + def withHeaders(headers: Seq[HttpHeader]): Self /** * Returns a new message that contains all of the given default headers which didn't already @@ -97,7 +96,7 @@ sealed trait HttpMessage extends jm.HttpMessage { * Returns a new message that contains all of the given default headers which didn't already * exist (by case-insensitive header name) in this message. */ - def withDefaultHeaders(defaultHeaders: immutable.Seq[HttpHeader]): Self = + def withDefaultHeaders(defaultHeaders: Seq[HttpHeader]): Self = withHeaders { if (headers.isEmpty) defaultHeaders else defaultHeaders.foldLeft(headers) { (acc, h) => if (headers.exists(_.is(h.lowercaseName))) acc else h +: acc } @@ -118,10 +117,10 @@ sealed trait HttpMessage extends jm.HttpMessage { entity.toStrict(timeout, maxBytes).fast.map(this.withEntity) /** Returns a copy of this message with the entity and headers set to the given ones. */ - def withHeadersAndEntity(headers: immutable.Seq[HttpHeader], entity: MessageEntity): Self + def withHeadersAndEntity(headers: Seq[HttpHeader], entity: MessageEntity): Self /** Returns a copy of this message with the list of headers transformed by the given function */ - def mapHeaders(f: immutable.Seq[HttpHeader] => immutable.Seq[HttpHeader]): Self = withHeaders(f(headers)) + def mapHeaders(f: Seq[HttpHeader] => Seq[HttpHeader]): Self = withHeaders(f(headers)) /** Returns a copy of this message with the attributes transformed by the given function */ def mapAttributes(f: Map[AttributeKey[?], ?] => Map[AttributeKey[?], ?]): Self = withAttributes(f(attributes)) @@ -146,7 +145,7 @@ sealed trait HttpMessage extends jm.HttpMessage { } /** Returns all the headers of the given type * */ - def headers[T <: jm.HttpHeader](implicit ct: ClassTag[T]): immutable.Seq[T] = headers.collect { + def headers[T <: jm.HttpHeader](implicit ct: ClassTag[T]): Seq[T] = headers.collect { case h: T => h } @@ -202,7 +201,7 @@ sealed trait HttpMessage extends jm.HttpMessage { import scala.jdk.CollectionConverters._ /** Java API */ - def getHeaders: JIterable[jm.HttpHeader] = (headers: immutable.Seq[jm.HttpHeader]).asJava + def getHeaders: JIterable[jm.HttpHeader] = (headers: Seq[jm.HttpHeader]).asJava /** Java API */ def getHeader[T <: jm.HttpHeader](headerClass: Class[T]): Optional[T] = @@ -318,7 +317,7 @@ object HttpMessage { final class HttpRequest( val method: HttpMethod, val uri: Uri, - val headers: immutable.Seq[HttpHeader], + val headers: Seq[HttpHeader], val attributes: Map[AttributeKey[?], ?], val entity: RequestEntity, val protocol: HttpProtocol) @@ -357,20 +356,20 @@ final class HttpRequest( /** * All cookies provided by the client in one or more `Cookie` headers. */ - def cookies: immutable.Seq[HttpCookiePair] = for (case `Cookie`(cookies) <- headers; cookie <- cookies) yield cookie + def cookies: Seq[HttpCookiePair] = for (case `Cookie`(cookies) <- headers; cookie <- cookies) yield cookie /** * Determines whether this request can be safely retried, which is the case only of the request method is idempotent. */ def canBeRetried = method.isIdempotent - override def withHeaders(headers: immutable.Seq[HttpHeader]): HttpRequest = + override def withHeaders(headers: Seq[HttpHeader]): HttpRequest = if (headers eq this.headers) this else copyImpl(headers = headers) override def withAttributes(attributes: Map[AttributeKey[?], ?]): HttpRequest = if (attributes eq this.attributes) this else copyImpl(attributes = attributes) - override def withHeadersAndEntity(headers: immutable.Seq[HttpHeader], entity: RequestEntity): HttpRequest = + override def withHeadersAndEntity(headers: Seq[HttpHeader], entity: RequestEntity): HttpRequest = copyImpl(headers = headers, entity = entity) override def withEntity(entity: jm.RequestEntity): HttpRequest = copyImpl(entity = entity.asInstanceOf[RequestEntity]) override def withEntity(entity: MessageEntity): HttpRequest = copyImpl(entity = entity) @@ -400,7 +399,7 @@ final class HttpRequest( private def copyImpl( method: HttpMethod = method, uri: Uri = uri, - headers: immutable.Seq[HttpHeader] = headers, + headers: Seq[HttpHeader] = headers, attributes: Map[AttributeKey[?], ?] = attributes, entity: RequestEntity = entity, protocol: HttpProtocol = protocol) = new HttpRequest(method, uri, headers, attributes, entity, protocol) @@ -448,7 +447,7 @@ object HttpRequest { * include a valid [[pekko.http.scaladsl.model.headers.Host]] header or if URI authority and [[pekko.http.scaladsl.model.headers.Host]] header don't match. */ def effectiveUri( - uri: Uri, headers: immutable.Seq[HttpHeader], securedConnection: Boolean, defaultHostHeader: Host): Uri = { + uri: Uri, headers: Seq[HttpHeader], securedConnection: Boolean, defaultHostHeader: Host): Uri = { @tailrec def findHostAndWsUpgrade(it: Iterator[HttpHeader], host: OptionVal[Host] = OptionVal.None, wsUpgrade: Option[Boolean] = None): (OptionVal[Host], Boolean) = if (host.isDefined && wsUpgrade.isDefined || !it.hasNext) @@ -506,7 +505,7 @@ object HttpRequest { def apply( method: HttpMethod = HttpMethods.GET, uri: Uri = Uri./, - headers: immutable.Seq[HttpHeader] = Nil, + headers: Seq[HttpHeader] = Nil, entity: RequestEntity = HttpEntity.Empty, protocol: HttpProtocol = HttpProtocols.`HTTP/1.1`) = new HttpRequest(method, uri, headers, Map.empty, entity, protocol) @@ -519,7 +518,7 @@ object HttpRequest { */ final class HttpResponse( val status: StatusCode, - val headers: immutable.Seq[HttpHeader], + val headers: Seq[HttpHeader], val attributes: Map[AttributeKey[?], ?], val entity: ResponseEntity, val protocol: HttpProtocol) @@ -536,7 +535,7 @@ final class HttpResponse( override def isRequest = false override def isResponse = true - override def withHeaders(headers: immutable.Seq[HttpHeader]): HttpResponse = + override def withHeaders(headers: Seq[HttpHeader]): HttpResponse = if (headers eq this.headers) this else copyImpl(headers = headers) def withAttributes(attributes: Map[AttributeKey[?], ?]): HttpResponse = @@ -549,9 +548,9 @@ final class HttpResponse( override def withStatus(statusCode: pekko.http.javadsl.model.StatusCode): HttpResponse = copyImpl(status = statusCode.asInstanceOf[StatusCode]) - override def withHeadersAndEntity(headers: immutable.Seq[HttpHeader], entity: MessageEntity): HttpResponse = + override def withHeadersAndEntity(headers: Seq[HttpHeader], entity: MessageEntity): HttpResponse = withHeadersAndEntity(headers, entity: ResponseEntity) - def withHeadersAndEntity(headers: immutable.Seq[HttpHeader], entity: ResponseEntity): HttpResponse = + def withHeadersAndEntity(headers: Seq[HttpHeader], entity: ResponseEntity): HttpResponse = copyImpl(headers = headers, entity = entity) override def withEntity(entity: jm.ResponseEntity): HttpResponse = copyImpl(entity = entity.asInstanceOf[ResponseEntity]) @@ -565,7 +564,7 @@ final class HttpResponse( private def copyImpl( status: StatusCode = status, - headers: immutable.Seq[HttpHeader] = headers, + headers: Seq[HttpHeader] = headers, attributes: Map[AttributeKey[?], ?] = attributes, entity: ResponseEntity = entity, protocol: HttpProtocol = protocol) = new HttpResponse(status, headers, attributes, entity, protocol) @@ -605,7 +604,7 @@ object HttpResponse { def apply( status: StatusCode = StatusCodes.OK, - headers: immutable.Seq[HttpHeader] = Nil, + headers: Seq[HttpHeader] = Nil, entity: ResponseEntity = HttpEntity.Empty, protocol: HttpProtocol = HttpProtocols.`HTTP/1.1`) = new HttpResponse(status, headers, Map.empty, entity, protocol) diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/Multipart.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/Multipart.scala index bab470e3e3..1f46567fca 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/Multipart.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/Multipart.scala @@ -113,7 +113,7 @@ object Multipart { /** * The parts of this content as a strict collection. */ - def strictParts: immutable.Seq[Multipart.BodyPart.Strict] + def strictParts: Seq[Multipart.BodyPart.Strict] /** * Creates an entity from this multipart object using the specified boundary and logger. @@ -139,7 +139,7 @@ object Multipart { /** Java API */ override def getStrictParts: java.lang.Iterable[? <: jm.Multipart.BodyPart.Strict] = - (strictParts: immutable.Seq[jm.Multipart.BodyPart.Strict]).asJava + (strictParts: Seq[jm.Multipart.BodyPart.Strict]).asJava } /** @@ -155,7 +155,7 @@ object Multipart { /** * The headers the part carries. */ - def headers: immutable.Seq[HttpHeader] + def headers: Seq[HttpHeader] /** * The potentially present `Content-Disposition` header. @@ -185,7 +185,7 @@ object Multipart { def getEntity: jm.BodyPartEntity = entity /** Java API */ - def getHeaders: java.lang.Iterable[jm.HttpHeader] = (headers: immutable.Seq[jm.HttpHeader]).asJava + def getHeaders: java.lang.Iterable[jm.HttpHeader] = (headers: Seq[jm.HttpHeader]).asJava /** Java API */ def getContentDispositionHeader: Optional[jm.headers.ContentDisposition] = @@ -259,7 +259,7 @@ object Multipart { /** * Strict [[General]] multipart content. */ - case class Strict(mediaType: MediaType.Multipart, strictParts: immutable.Seq[Multipart.General.BodyPart.Strict]) + case class Strict(mediaType: MediaType.Multipart, strictParts: Seq[Multipart.General.BodyPart.Strict]) extends Multipart.General with Multipart.Strict with jm.Multipart.General.Strict { def parts: Source[Multipart.General.BodyPart.Strict, Any] = Source(strictParts) override def toStrict(timeout: FiniteDuration)(implicit fm: Materializer) = FastFuture.successful(this) @@ -292,7 +292,7 @@ object Multipart { Future[jm.Multipart.General.BodyPart.Strict]].asJava private[BodyPart] def tryCreateFormDataBodyPart[T]( - f: (String, Map[String, String], immutable.Seq[HttpHeader]) => T): Try[T] = { + f: (String, Map[String, String], Seq[HttpHeader]) => T): Try[T] = { val params = dispositionParams params.get("name") match { case Some(name) => Success(f(name, params - "name", headers.filterNot(_.is("content-disposition")))) @@ -301,17 +301,17 @@ object Multipart { } } private[BodyPart] def tryCreateByteRangesBodyPart[T]( - f: (ContentRange, RangeUnit, immutable.Seq[HttpHeader]) => T): Try[T] = + f: (ContentRange, RangeUnit, Seq[HttpHeader]) => T): Try[T] = headers.collectFirst { case x: `Content-Range` => x } match { case Some(`Content-Range`(unit, range)) => Success(f(range, unit, headers.filterNot(_.is("content-range")))) case None => Failure(IllegalHeaderException("multipart/byteranges part must contain `Content-Range` header")) } } object BodyPart { - def apply(_entity: BodyPartEntity, _headers: immutable.Seq[HttpHeader] = Nil): Multipart.General.BodyPart = + def apply(_entity: BodyPartEntity, _headers: Seq[HttpHeader] = Nil): Multipart.General.BodyPart = new Multipart.General.BodyPart { def entity = _entity - def headers: immutable.Seq[HttpHeader] = _headers + def headers: Seq[HttpHeader] = _headers def toFormDataBodyPart: Try[Multipart.FormData.BodyPart] = tryCreateFormDataBodyPart(FormData.BodyPart(_, entity, _, _)) def toByteRangesBodyPart: Try[Multipart.ByteRanges.BodyPart] = @@ -319,13 +319,13 @@ object Multipart { override def toString = s"General.BodyPart($entity, $headers)" } - def unapply(value: BodyPart): Option[(BodyPartEntity, immutable.Seq[HttpHeader])] = + def unapply(value: BodyPart): Option[(BodyPartEntity, Seq[HttpHeader])] = Some(value.entity -> value.headers) /** * Strict [[General.BodyPart]]. */ - case class Strict(entity: HttpEntity.Strict, headers: immutable.Seq[HttpHeader] = Nil) + case class Strict(entity: HttpEntity.Strict, headers: Seq[HttpHeader] = Nil) extends BodyPart with Multipart.BodyPart.Strict with jm.Multipart.General.BodyPart.Strict { override def toStrict(timeout: FiniteDuration)( implicit fm: Materializer): Future[Multipart.General.BodyPart.Strict] = @@ -428,7 +428,7 @@ object Multipart { /** * Strict [[FormData]]. */ - case class Strict(strictParts: immutable.Seq[Multipart.FormData.BodyPart.Strict]) + case class Strict(strictParts: Seq[Multipart.FormData.BodyPart.Strict]) extends FormData with Multipart.Strict with jm.Multipart.FormData.Strict { def parts: Source[Multipart.FormData.BodyPart.Strict, Any] = Source(strictParts) override def toStrict(timeout: FiniteDuration)(implicit fm: Materializer) = FastFuture.successful(this) @@ -461,7 +461,7 @@ object Multipart { /** * Part headers, not including the Content-Disposition header. */ - def additionalHeaders: immutable.Seq[HttpHeader] + def additionalHeaders: Seq[HttpHeader] override def headers = contentDispositionHeader.get +: additionalHeaders override def contentDispositionHeader = Some(`Content-Disposition`(dispositionType.get, dispositionParams)) @@ -487,7 +487,7 @@ object Multipart { /** Java API */ def getAdditionalHeaders: java.lang.Iterable[jm.HttpHeader] = - (additionalHeaders: immutable.Seq[jm.HttpHeader]).asJava + (additionalHeaders: Seq[jm.HttpHeader]).asJava /** Java API */ def getFilename: Optional[String] = filename.asJava @@ -501,7 +501,7 @@ object Multipart { object BodyPart { def apply(_name: String, _entity: BodyPartEntity, _additionalDispositionParams: Map[String, String] = Map.empty, - _additionalHeaders: immutable.Seq[HttpHeader] = Nil): Multipart.FormData.BodyPart = + _additionalHeaders: Seq[HttpHeader] = Nil): Multipart.FormData.BodyPart = new Multipart.FormData.BodyPart { def name = _name def additionalDispositionParams = _additionalDispositionParams @@ -522,7 +522,7 @@ object Multipart { def fromPath(name: String, contentType: ContentType, file: Path, chunkSize: Int = -1): BodyPart = BodyPart(name, HttpEntity.fromPath(contentType, file, chunkSize), Map("filename" -> file.getFileName.toString)) - def unapply(value: BodyPart): Option[(String, BodyPartEntity, Map[String, String], immutable.Seq[HttpHeader])] = + def unapply(value: BodyPart): Option[(String, BodyPartEntity, Map[String, String], Seq[HttpHeader])] = Some((value.name, value.entity, value.additionalDispositionParams, value.additionalHeaders)) /** @@ -530,7 +530,7 @@ object Multipart { */ case class Strict(name: String, entity: HttpEntity.Strict, additionalDispositionParams: Map[String, String] = Map.empty, - additionalHeaders: immutable.Seq[HttpHeader] = Nil) + additionalHeaders: Seq[HttpHeader] = Nil) extends Multipart.FormData.BodyPart with Multipart.BodyPart.Strict with jm.Multipart.FormData.BodyPart.Strict { override def toStrict(timeout: FiniteDuration)( @@ -545,7 +545,7 @@ object Multipart { def create(_name: String, _entity: BodyPartEntity, _additionalDispositionParams: Map[String, String], _additionalHeaders: Iterable[pekko.http.javadsl.model.HttpHeader]): Multipart.FormData.BodyPart = { - val _headers = _additionalHeaders.to(immutable.Seq).map { case h: pekko.http.scaladsl.model.HttpHeader => h } + val _headers = _additionalHeaders.to(Seq).map { case h: pekko.http.scaladsl.model.HttpHeader => h } apply(_name, _entity, _additionalDispositionParams, _headers) } } @@ -556,7 +556,7 @@ object Multipart { def createStrict(_name: String, _entity: HttpEntity.Strict, _additionalDispositionParams: Map[String, String], _additionalHeaders: Iterable[pekko.http.javadsl.model.HttpHeader]): Multipart.FormData.BodyPart.Strict = { - val _headers = _additionalHeaders.to(immutable.Seq).map { case h: pekko.http.scaladsl.model.HttpHeader => h } + val _headers = _additionalHeaders.to(Seq).map { case h: pekko.http.scaladsl.model.HttpHeader => h } Strict(_name, _entity, _additionalDispositionParams, _headers) } } @@ -596,7 +596,7 @@ object Multipart { /** * Strict [[ByteRanges]]. */ - case class Strict(strictParts: immutable.Seq[Multipart.ByteRanges.BodyPart.Strict]) + case class Strict(strictParts: Seq[Multipart.ByteRanges.BodyPart.Strict]) extends Multipart.ByteRanges with Multipart.Strict with jm.Multipart.ByteRanges.Strict { def parts: Source[Multipart.ByteRanges.BodyPart.Strict, Any] = Source(strictParts) override def toStrict(timeout: FiniteDuration)(implicit fm: Materializer) = FastFuture.successful(this) @@ -629,7 +629,7 @@ object Multipart { /** * Part headers, not including the Content-Range header. */ - def additionalHeaders: immutable.Seq[HttpHeader] + def additionalHeaders: Seq[HttpHeader] /** * The `Content-Range` header of this part. @@ -651,7 +651,7 @@ object Multipart { /** Java API */ def getAdditionalHeaders: java.lang.Iterable[jm.HttpHeader] = - (additionalHeaders: immutable.Seq[jm.HttpHeader]).asJava + (additionalHeaders: Seq[jm.HttpHeader]).asJava /** Java API */ def getContentRangeHeader: jm.headers.ContentRange = contentRangeHeader @@ -664,7 +664,7 @@ object Multipart { } object BodyPart { def apply(_contentRange: ContentRange, _entity: BodyPartEntity, _rangeUnit: RangeUnit = RangeUnits.Bytes, - _additionalHeaders: immutable.Seq[HttpHeader] = Nil): Multipart.ByteRanges.BodyPart = + _additionalHeaders: Seq[HttpHeader] = Nil): Multipart.ByteRanges.BodyPart = new Multipart.ByteRanges.BodyPart { def contentRange = _contentRange def entity = _entity @@ -674,14 +674,14 @@ object Multipart { } def unapply(value: Multipart.ByteRanges.BodyPart) - : Option[(ContentRange, BodyPartEntity, RangeUnit, immutable.Seq[HttpHeader])] = + : Option[(ContentRange, BodyPartEntity, RangeUnit, Seq[HttpHeader])] = Some((value.contentRange, value.entity, value.rangeUnit, value.additionalHeaders)) /** * Strict [[ByteRanges.BodyPart]]. */ case class Strict(contentRange: ContentRange, entity: HttpEntity.Strict, rangeUnit: RangeUnit = RangeUnits.Bytes, - additionalHeaders: immutable.Seq[HttpHeader] = Nil) + additionalHeaders: Seq[HttpHeader] = Nil) extends Multipart.ByteRanges.BodyPart with Multipart.BodyPart.Strict with jm.Multipart.ByteRanges.BodyPart.Strict { override def toStrict(timeout: FiniteDuration)( diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/Trailer.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/Trailer.scala index 0489e2bbc8..1b4090b210 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/Trailer.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/Trailer.scala @@ -17,9 +17,7 @@ import org.apache.pekko import pekko.annotation.ApiMayChange import pekko.http.javadsl.{ model => jm } -import scala.collection.immutable - -class Trailer(@ApiMayChange val headers: immutable.Seq[(String, String)]) extends jm.Trailer { +class Trailer(@ApiMayChange val headers: Seq[(String, String)]) extends jm.Trailer { /** * Java API @@ -38,11 +36,11 @@ class Trailer(@ApiMayChange val headers: immutable.Seq[(String, String)]) extend /** * Java API */ - override def withHeaders(headers: Iterable[jm.HttpHeader]): Trailer = Trailer(immutable.Seq.empty).addHeaders(headers) + override def withHeaders(headers: Iterable[jm.HttpHeader]): Trailer = Trailer(Seq.empty).addHeaders(headers) } object Trailer { - def apply(): Trailer = new Trailer(immutable.Seq.empty) + def apply(): Trailer = new Trailer(Seq.empty) def apply(header: HttpHeader): Trailer = - new Trailer(immutable.Seq(header).map(h => (h.name, h.value))) - def apply(headers: immutable.Seq[HttpHeader]) = new Trailer(immutable.Seq.empty).addHeaders(headers) + new Trailer(Seq(header).map(h => (h.name, h.value))) + def apply(headers: Seq[HttpHeader]) = new Trailer(Seq.empty).addHeaders(headers) } diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/Uri.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/Uri.scala index 1ea4ba2adc..454298d268 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/Uri.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/Uri.scala @@ -18,7 +18,7 @@ import java.lang.{ Iterable, StringBuilder => JStringBuilder } import java.nio.charset.Charset import scala.annotation.tailrec -import scala.collection.{ immutable, mutable } +import scala.collection.mutable import org.apache.pekko import pekko.annotation.DoNotInherit @@ -447,7 +447,7 @@ object Uri { def address: String def isEmpty: Boolean def toOption: Option[NonEmptyHost] - def inetAddresses: immutable.Seq[InetAddress] + def inetAddresses: Seq[InetAddress] def equalsIgnoreCase(other: Host): Boolean override def toString = UriRendering.HostRenderer.render(new StringRendering, this).get @@ -468,7 +468,7 @@ object Uri { def address: String = "" def isEmpty = true def toOption = None - def inetAddresses: immutable.Seq[InetAddress] = Nil + def inetAddresses: Seq[InetAddress] = Nil def equalsIgnoreCase(other: Host): Boolean = other eq this } @@ -489,7 +489,7 @@ object Uri { def isEmpty = false def toOption = Some(this) } - final case class IPv4Host private[http] (bytes: immutable.Seq[Byte], address: String) extends NonEmptyHost { + final case class IPv4Host private[http] (bytes: Seq[Byte], address: String) extends NonEmptyHost { require(bytes.length == 4, "bytes array must have length 4") require(!address.isEmpty, "address must not be empty") def equalsIgnoreCase(other: Host): Boolean = other match { @@ -498,7 +498,7 @@ object Uri { } override def isIPv4: Boolean = true - def inetAddresses = immutable.Seq(InetAddress.getByAddress(bytes.toArray)) + def inetAddresses = Seq(InetAddress.getByAddress(bytes.toArray)) } object IPv4Host { def apply(address: String): IPv4Host = apply(address.split('.').map(_.toInt.toByte)) @@ -508,7 +508,7 @@ object Uri { private[http] def apply(bytes: Array[Byte], address: String): IPv4Host = IPv4Host(bytes.toSeq, address) } - final case class IPv6Host private (bytes: immutable.Seq[Byte], address: String) extends NonEmptyHost { + final case class IPv6Host private (bytes: Seq[Byte], address: String) extends NonEmptyHost { require(bytes.length == 16, "bytes array must have length 16") require(!address.isEmpty, "address must not be empty") def equalsIgnoreCase(other: Host): Boolean = other match { @@ -517,11 +517,11 @@ object Uri { } override def isIPv6: Boolean = true - def inetAddresses = immutable.Seq(InetAddress.getByAddress(bytes.toArray)) + def inetAddresses = Seq(InetAddress.getByAddress(bytes.toArray)) } object IPv6Host { def apply(bytes: Array[Byte]): IPv6Host = Host(InetAddress.getByAddress(bytes).asInstanceOf[Inet6Address]) - def apply(bytes: immutable.Seq[Byte]): IPv6Host = apply(bytes.toArray) + def apply(bytes: Seq[Byte]): IPv6Host = apply(bytes.toArray) private[http] def apply(bytes: String, address: String): IPv6Host = { import CharUtils.{ hexValue => hex } diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/CacheDirective.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/CacheDirective.scala index 58b4fd30f9..6c1b92eb0b 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/CacheDirective.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/CacheDirective.scala @@ -17,7 +17,6 @@ import org.apache.pekko import pekko.annotation.ApiMayChange import scala.annotation.{ tailrec, varargs } -import scala.collection.immutable import pekko.http.impl.util._ import pekko.http.javadsl.{ model => jm } @@ -41,7 +40,7 @@ object CacheDirective { CustomCacheDirective(name, content) sealed abstract class FieldNamesDirective extends Product with ValueRenderable { - def fieldNames: immutable.Seq[String] + def fieldNames: Seq[String] final def render[R <: Rendering](r: R): r.type = if (fieldNames.nonEmpty) { r ~~ productPrefix ~~ '=' ~~ '"' @@ -126,7 +125,7 @@ object CacheDirectives { * For a fuller description of the use case, see * http://tools.ietf.org/html/rfc7234#section-5.2.2.2 */ - final case class `no-cache`(fieldNames: immutable.Seq[String]) extends FieldNamesDirective with ResponseDirective + final case class `no-cache`(fieldNames: Seq[String]) extends FieldNamesDirective with ResponseDirective /** * For a fuller description of the use case, see @@ -141,15 +140,15 @@ object CacheDirectives { * For a fuller description of the use case, see * http://tools.ietf.org/html/rfc7234#section-5.2.2.6 */ - final case class `private`(fieldNames: immutable.Seq[String]) extends FieldNamesDirective with ResponseDirective + final case class `private`(fieldNames: Seq[String]) extends FieldNamesDirective with ResponseDirective object `private` { - def apply(): `private` = new `private`(immutable.Seq.empty) + def apply(): `private` = new `private`(Seq.empty) def apply(firstFieldName: String, otherFieldNames: String*): `private` = new `private`(firstFieldName +: otherFieldNames) } /** Java API */ - @varargs def createPrivate(fieldNames: String*): ResponseDirective = new `private`(immutable.Seq(fieldNames: _*)) + @varargs def createPrivate(fieldNames: String*): ResponseDirective = new `private`(Seq(fieldNames: _*)) /** * For a fuller description of the use case, see diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/EntityTag.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/EntityTag.scala index c0bfe0274f..b7058da4ab 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/EntityTag.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/EntityTag.scala @@ -35,7 +35,7 @@ object EntityTag { sealed abstract class EntityTagRange extends jm.headers.EntityTagRange with ValueRenderable object EntityTagRange { - def apply(tags: EntityTag*) = Default(immutable.Seq(tags: _*)) + def apply(tags: EntityTag*) = Default(Seq(tags: _*)) implicit val tagsRenderer: Renderer[immutable.Iterable[EntityTag]] = Renderer.defaultSeqRenderer[EntityTag] // cache @@ -43,7 +43,7 @@ object EntityTagRange { def render[R <: Rendering](r: R): r.type = r ~~ '*' } - final case class Default(tags: immutable.Seq[EntityTag]) extends EntityTagRange { + final case class Default(tags: Seq[EntityTag]) extends EntityTagRange { require(tags.nonEmpty, "tags must not be empty") def render[R <: Rendering](r: R): r.type = r ~~ tags } diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/HttpOrigin.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/HttpOrigin.scala index 07b1d09547..a81f248277 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/HttpOrigin.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/HttpOrigin.scala @@ -21,8 +21,6 @@ import pekko.http.javadsl.{ model => jm } import pekko.http.scaladsl.model.Uri import org.parboiled2.UTF8 -import scala.collection.immutable - abstract class HttpOriginRange extends jm.headers.HttpOriginRange with ValueRenderable { def matches(origin: HttpOrigin): Boolean @@ -36,9 +34,9 @@ object HttpOriginRange { def render[R <: Rendering](r: R): r.type = r ~~ '*' } - def apply(origins: HttpOrigin*): Default = Default(immutable.Seq(origins: _*)) + def apply(origins: HttpOrigin*): Default = Default(Seq(origins: _*)) - final case class Default(origins: immutable.Seq[HttpOrigin]) extends HttpOriginRange { + final case class Default(origins: Seq[HttpOrigin]) extends HttpOriginRange { def matches(origin: HttpOrigin): Boolean = origins contains origin def render[R <: Rendering](r: R): r.type = r ~~ origins } @@ -50,7 +48,7 @@ final case class HttpOrigin(scheme: String, host: Host) extends jm.headers.HttpO } object HttpOrigin { - implicit val originsRenderer: Renderer[immutable.Seq[HttpOrigin]] = Renderer.seqRenderer(" ", "null") + implicit val originsRenderer: Renderer[Seq[HttpOrigin]] = Renderer.seqRenderer(" ", "null") implicit def apply(str: String): HttpOrigin = { val parser = new UriParser(str, UTF8, Uri.ParsingMode.Relaxed) diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/LanguageRange.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/LanguageRange.scala index 4cb898a32a..b15b98260c 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/LanguageRange.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/LanguageRange.scala @@ -24,7 +24,7 @@ import pekko.http.impl.util.JavaMapping.Implicits._ sealed trait LanguageRange extends jm.headers.LanguageRange with ValueRenderable with WithQValue[LanguageRange] { def qValue: Float def primaryTag: String - def subTags: immutable.Seq[String] + def subTags: Seq[String] def matches(lang: Language): Boolean final def render[R <: Rendering](r: R): r.type = { r ~~ primaryTag @@ -63,7 +63,7 @@ object LanguageRange { def apply(language: Language, qValue: Float): LanguageRange = One(language, qValue) } -final case class Language(primaryTag: String, subTags: immutable.Seq[String]) +final case class Language(primaryTag: String, subTags: Seq[String]) extends jm.headers.Language with ValueRenderable with WithQValue[LanguageRange] { def withQValue(qValue: Float) = LanguageRange(this, qValue.toFloat) def render[R <: Rendering](r: R): r.type = { @@ -80,7 +80,7 @@ object Language { if (compoundTag.indexOf('-') >= 0) { val tags = compoundTag.split('-') new Language(tags.head, immutable.ArraySeq.unsafeWrapArray(tags.tail)) - } else new Language(compoundTag, immutable.Seq.empty) + } else new Language(compoundTag, Seq.empty) def apply(primaryTag: String, firstSubTag: String, otherSubTags: String*): Language = new Language(primaryTag, firstSubTag +: otherSubTags) diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/LinkValue.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/LinkValue.scala index 6bbd6cd856..c83a053240 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/LinkValue.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/LinkValue.scala @@ -13,7 +13,6 @@ package org.apache.pekko.http.scaladsl.model.headers -import scala.collection.immutable import org.apache.pekko import pekko.http.impl.util._ import pekko.http.scaladsl.model._ @@ -22,7 +21,7 @@ import pekko.http.impl.util.JavaMapping.Implicits._ import UriRendering.UriRenderer import org.parboiled2.CharPredicate -final case class LinkValue(uri: Uri, params: immutable.Seq[LinkParam]) extends jm.headers.LinkValue +final case class LinkValue(uri: Uri, params: Seq[LinkParam]) extends jm.headers.LinkValue with ValueRenderable { def render[R <: Rendering](r: R): r.type = { r ~~ '<' ~~ uri ~~ '>' @@ -43,7 +42,7 @@ sealed abstract class LinkParam extends jm.headers.LinkParam with ToStringRender def value: AnyRef } object LinkParam { - implicit val paramsRenderer: Renderer[immutable.Seq[LinkParam]] = Renderer.seqRenderer(separator = "; ") + implicit val paramsRenderer: Renderer[Seq[LinkParam]] = Renderer.seqRenderer(separator = "; ") } object LinkParams { diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/ProductVersion.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/ProductVersion.scala index 39370582b3..278cb3d85b 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/ProductVersion.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/ProductVersion.scala @@ -13,7 +13,6 @@ package org.apache.pekko.http.scaladsl.model.headers -import scala.collection.immutable import scala.util.{ Failure, Success } import org.apache.pekko import org.parboiled2.ParseError @@ -35,16 +34,16 @@ final case class ProductVersion(product: String = "", version: String = "", comm } object ProductVersion { - implicit val productsRenderer: Renderer[immutable.Seq[ProductVersion]] = + implicit val productsRenderer: Renderer[Seq[ProductVersion]] = Renderer.seqRenderer[ProductVersion](separator = " ") /** parses a string of multiple ProductVersions */ - def parseMultiple(string: String): immutable.Seq[ProductVersion] = { + def parseMultiple(string: String): Seq[ProductVersion] = { val parser = new HeaderParser(string) def fail(msg: String) = throw new IllegalArgumentException(s"'$string' is not a legal sequence of ProductVersions: $msg") parser.products.run() match { - case Success(x) => immutable.Seq(x: _*) + case Success(x) => Seq(x: _*) case Failure(e: ParseError) => fail(parser.formatError(e)) case Failure(e) => fail(e.getMessage) } diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/headers.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/headers.scala index 2a7919ec89..17adc8486c 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/headers.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/headers.scala @@ -153,7 +153,7 @@ object Accept extends ModeledCompanion[Accept] { apply(firstMediaRange +: otherMediaRanges) implicit val mediaRangesRenderer: Renderer[immutable.Iterable[MediaRange]] = Renderer.defaultSeqRenderer[MediaRange] // cache } -final case class Accept(mediaRanges: immutable.Seq[MediaRange]) extends jm.headers.Accept with RequestHeader { +final case class Accept(mediaRanges: Seq[MediaRange]) extends jm.headers.Accept with RequestHeader { import Accept.mediaRangesRenderer def renderValue[R <: Rendering](r: R): r.type = r ~~ mediaRanges protected def companion = Accept @@ -166,11 +166,11 @@ final case class Accept(mediaRanges: immutable.Seq[MediaRange]) extends jm.heade // https://tools.ietf.org/html/rfc7231#section-5.3.3 object `Accept-Charset` extends ModeledCompanion[`Accept-Charset`] { def apply(first: HttpCharsetRange, more: HttpCharsetRange*): `Accept-Charset` = - apply(immutable.Seq(first +: more: _*)) + apply(Seq(first +: more: _*)) implicit val charsetRangesRenderer: Renderer[immutable.Iterable[HttpCharsetRange]] = Renderer.defaultSeqRenderer[HttpCharsetRange] // cache } -final case class `Accept-Charset`(charsetRanges: immutable.Seq[HttpCharsetRange]) extends jm.headers.AcceptCharset +final case class `Accept-Charset`(charsetRanges: Seq[HttpCharsetRange]) extends jm.headers.AcceptCharset with RequestHeader { require(charsetRanges.nonEmpty, "charsetRanges must not be empty") import `Accept-Charset`.charsetRangesRenderer @@ -184,13 +184,13 @@ final case class `Accept-Charset`(charsetRanges: immutable.Seq[HttpCharsetRange] // https://tools.ietf.org/html/rfc7231#section-5.3.4 object `Accept-Encoding` extends ModeledCompanion[`Accept-Encoding`] { def apply(): `Accept-Encoding` = - apply(immutable.Seq.empty) + apply(Seq.empty) def apply(firstEncoding: HttpEncodingRange, otherEncodings: HttpEncodingRange*): `Accept-Encoding` = apply(firstEncoding +: otherEncodings) implicit val encodingsRenderer: Renderer[immutable.Iterable[HttpEncodingRange]] = Renderer.defaultSeqRenderer[HttpEncodingRange] // cache } -final case class `Accept-Encoding`(encodings: immutable.Seq[HttpEncodingRange]) extends jm.headers.AcceptEncoding +final case class `Accept-Encoding`(encodings: Seq[HttpEncodingRange]) extends jm.headers.AcceptEncoding with RequestHeader { import `Accept-Encoding`.encodingsRenderer def renderValue[R <: Rendering](r: R): r.type = r ~~ encodings @@ -202,11 +202,11 @@ final case class `Accept-Encoding`(encodings: immutable.Seq[HttpEncodingRange]) // https://tools.ietf.org/html/rfc7231#section-5.3.5 object `Accept-Language` extends ModeledCompanion[`Accept-Language`] { - def apply(first: LanguageRange, more: LanguageRange*): `Accept-Language` = apply(immutable.Seq(first +: more: _*)) + def apply(first: LanguageRange, more: LanguageRange*): `Accept-Language` = apply(Seq(first +: more: _*)) implicit val languagesRenderer: Renderer[immutable.Iterable[LanguageRange]] = Renderer.defaultSeqRenderer[LanguageRange] // cache } -final case class `Accept-Language`(languages: immutable.Seq[LanguageRange]) extends jm.headers.AcceptLanguage +final case class `Accept-Language`(languages: Seq[LanguageRange]) extends jm.headers.AcceptLanguage with RequestHeader { require(languages.nonEmpty, "languages must not be empty") import `Accept-Language`.languagesRenderer @@ -220,12 +220,12 @@ final case class `Accept-Language`(languages: immutable.Seq[LanguageRange]) exte // https://tools.ietf.org/html/rfc7233#section-2.3 object `Accept-Ranges` extends ModeledCompanion[`Accept-Ranges`] { def apply(): `Accept-Ranges` = - apply(immutable.Seq.empty) + apply(Seq.empty) def apply(firstRangeUnit: RangeUnit, otherRangeUnits: RangeUnit*): `Accept-Ranges` = apply(firstRangeUnit +: otherRangeUnits) implicit val rangeUnitsRenderer: Renderer[immutable.Iterable[RangeUnit]] = Renderer.defaultSeqRenderer[RangeUnit] // cache } -final case class `Accept-Ranges`(rangeUnits: immutable.Seq[RangeUnit]) extends jm.headers.AcceptRanges +final case class `Accept-Ranges`(rangeUnits: Seq[RangeUnit]) extends jm.headers.AcceptRanges with ResponseHeader { import `Accept-Ranges`.rangeUnitsRenderer def renderValue[R <: Rendering](r: R): r.type = if (rangeUnits.isEmpty) r ~~ "none" else r ~~ rangeUnits @@ -279,7 +279,7 @@ object `Accept-Query` extends ModeledCompanion[`Accept-Query`] { private def isSfTokenStart(ch: Char): Boolean = CharacterClasses.ALPHA(ch) || ch == '*' } -final case class `Accept-Query`(mediaRanges: immutable.Seq[MediaRange]) extends jm.headers.AcceptQuery +final case class `Accept-Query`(mediaRanges: Seq[MediaRange]) extends jm.headers.AcceptQuery with ResponseHeader { import `Accept-Query`.mediaRangesRenderer def renderValue[R <: Rendering](r: R): r.type = r ~~ mediaRanges @@ -303,7 +303,7 @@ object `Access-Control-Allow-Headers` extends ModeledCompanion[`Access-Control-A apply(firstHeader +: otherHeaders) implicit val headersRenderer: Renderer[immutable.Iterable[String]] = Renderer.defaultSeqRenderer[String] // cache } -final case class `Access-Control-Allow-Headers`(headers: immutable.Seq[String]) +final case class `Access-Control-Allow-Headers`(headers: Seq[String]) extends jm.headers.AccessControlAllowHeaders with ResponseHeader { import `Access-Control-Allow-Headers`.headersRenderer def renderValue[R <: Rendering](r: R): r.type = r ~~ headers @@ -319,7 +319,7 @@ object `Access-Control-Allow-Methods` extends ModeledCompanion[`Access-Control-A apply(firstMethod +: otherMethods) implicit val methodsRenderer: Renderer[immutable.Iterable[HttpMethod]] = Renderer.defaultSeqRenderer[HttpMethod] // cache } -final case class `Access-Control-Allow-Methods`(methods: immutable.Seq[HttpMethod]) +final case class `Access-Control-Allow-Methods`(methods: Seq[HttpMethod]) extends jm.headers.AccessControlAllowMethods with ResponseHeader { import `Access-Control-Allow-Methods`.methodsRenderer def renderValue[R <: Rendering](r: R): r.type = r ~~ methods @@ -356,7 +356,7 @@ object `Access-Control-Expose-Headers` extends ModeledCompanion[`Access-Control- apply(firstHeader +: otherHeaders) implicit val headersRenderer: Renderer[immutable.Iterable[String]] = Renderer.defaultSeqRenderer[String] // cache } -final case class `Access-Control-Expose-Headers`(headers: immutable.Seq[String]) +final case class `Access-Control-Expose-Headers`(headers: Seq[String]) extends jm.headers.AccessControlExposeHeaders with ResponseHeader { import `Access-Control-Expose-Headers`.headersRenderer def renderValue[R <: Rendering](r: R): r.type = r ~~ headers @@ -380,7 +380,7 @@ object `Access-Control-Request-Headers` extends ModeledCompanion[`Access-Control apply(firstHeader +: otherHeaders) implicit val headersRenderer: Renderer[immutable.Iterable[String]] = Renderer.defaultSeqRenderer[String] // cache } -final case class `Access-Control-Request-Headers`(headers: immutable.Seq[String]) +final case class `Access-Control-Request-Headers`(headers: Seq[String]) extends jm.headers.AccessControlRequestHeaders with RequestHeader { import `Access-Control-Request-Headers`.headersRenderer def renderValue[R <: Rendering](r: R): r.type = r ~~ headers @@ -408,12 +408,12 @@ final case class Age(deltaSeconds: Long) extends jm.headers.Age with ResponseHea // https://tools.ietf.org/html/rfc7231#section-7.4.1 object Allow extends ModeledCompanion[Allow] { def apply(): `Allow` = - apply(immutable.Seq.empty) + apply(Seq.empty) def apply(firstMethod: HttpMethod, otherMethods: HttpMethod*): Allow = apply(firstMethod +: otherMethods) implicit val methodsRenderer: Renderer[immutable.Iterable[HttpMethod]] = Renderer.defaultSeqRenderer[HttpMethod] // cache } -final case class Allow(methods: immutable.Seq[HttpMethod]) extends jm.headers.Allow with ResponseHeader { +final case class Allow(methods: Seq[HttpMethod]) extends jm.headers.Allow with ResponseHeader { import Allow.methodsRenderer def renderValue[R <: Rendering](r: R): r.type = r ~~ methods protected def companion = Allow @@ -432,11 +432,11 @@ final case class Authorization(credentials: HttpCredentials) extends jm.headers. // https://tools.ietf.org/html/rfc7234#section-5.2 object `Cache-Control` extends ModeledCompanion[`Cache-Control`] { - def apply(first: CacheDirective, more: CacheDirective*): `Cache-Control` = apply(immutable.Seq(first +: more: _*)) + def apply(first: CacheDirective, more: CacheDirective*): `Cache-Control` = apply(Seq(first +: more: _*)) implicit val directivesRenderer: Renderer[immutable.Iterable[CacheDirective]] = Renderer.defaultSeqRenderer[CacheDirective] // cache } -final case class `Cache-Control`(directives: immutable.Seq[CacheDirective]) extends jm.headers.CacheControl +final case class `Cache-Control`(directives: Seq[CacheDirective]) extends jm.headers.CacheControl with RequestResponseHeader { require(directives.nonEmpty, "directives must not be empty") import `Cache-Control`.directivesRenderer @@ -449,10 +449,10 @@ final case class `Cache-Control`(directives: immutable.Seq[CacheDirective]) exte // https://tools.ietf.org/html/rfc7230#section-6.1 object Connection extends ModeledCompanion[Connection] { - def apply(first: String, more: String*): Connection = apply(immutable.Seq(first +: more: _*)) + def apply(first: String, more: String*): Connection = apply(Seq(first +: more: _*)) implicit val tokensRenderer: Renderer[immutable.Iterable[String]] = Renderer.defaultSeqRenderer[String] // cache } -final case class Connection(tokens: immutable.Seq[String]) extends jm.headers.Connection +final case class Connection(tokens: Seq[String]) extends jm.headers.Connection with RequestResponseHeader { require(tokens.nonEmpty, "tokens must not be empty") import Connection.tokensRenderer @@ -460,7 +460,7 @@ final case class Connection(tokens: immutable.Seq[String]) extends jm.headers.Co def hasClose = has("close") def hasKeepAlive = has("keep-alive") def hasUpgrade = has("upgrade") - def append(tokens: immutable.Seq[String]) = Connection(this.tokens ++ tokens) + def append(tokens: Seq[String]) = Connection(this.tokens ++ tokens) @tailrec private def has(item: String, ix: Int = 0): Boolean = if (ix < tokens.length) if (tokens(ix).equalsIgnoreCase(item)) true @@ -544,10 +544,10 @@ final case class `Content-Disposition`(dispositionType: ContentDispositionType, // https://tools.ietf.org/html/rfc7231#section-3.1.2.2 object `Content-Encoding` extends ModeledCompanion[`Content-Encoding`] { - def apply(first: HttpEncoding, more: HttpEncoding*): `Content-Encoding` = apply(immutable.Seq(first +: more: _*)) + def apply(first: HttpEncoding, more: HttpEncoding*): `Content-Encoding` = apply(Seq(first +: more: _*)) implicit val encodingsRenderer: Renderer[immutable.Iterable[HttpEncoding]] = Renderer.defaultSeqRenderer[HttpEncoding] // cache } -final case class `Content-Encoding`(encodings: immutable.Seq[HttpEncoding]) extends jm.headers.ContentEncoding +final case class `Content-Encoding`(encodings: Seq[HttpEncoding]) extends jm.headers.ContentEncoding with RequestResponseHeader { require(encodings.nonEmpty, "encodings must not be empty") import `Content-Encoding`.encodingsRenderer @@ -583,13 +583,13 @@ final case class `Content-Type` private[pekko] (contentType: ContentType) extend // https://tools.ietf.org/html/rfc6265#section-4.2 object Cookie extends ModeledCompanion[Cookie] { - def apply(first: HttpCookiePair, more: HttpCookiePair*): Cookie = apply(immutable.Seq(first +: more: _*)) + def apply(first: HttpCookiePair, more: HttpCookiePair*): Cookie = apply(Seq(first +: more: _*)) def apply(name: String, value: String): Cookie = apply(HttpCookiePair(name, value)) def apply(first: (String, String), more: (String, String)*): Cookie = apply((first +: more).map(HttpCookiePair(_))) implicit val cookiePairsRenderer: Renderer[immutable.Iterable[HttpCookiePair]] = Renderer.seqRenderer[HttpCookiePair](separator = "; ") // cache } -final case class Cookie(cookies: immutable.Seq[HttpCookiePair]) extends jm.headers.Cookie with RequestHeader +final case class Cookie(cookies: Seq[HttpCookiePair]) extends jm.headers.Cookie with RequestHeader with SensitiveHttpHeader { require(cookies.nonEmpty, "cookies must not be empty") import Cookie.cookiePairsRenderer @@ -733,12 +733,12 @@ final case class `Last-Modified`(date: DateTime) extends jm.headers.LastModified // https://tools.ietf.org/html/rfc5988#section-5 object Link extends ModeledCompanion[Link] { def apply(uri: Uri, first: LinkParam, more: LinkParam*): Link = - apply(immutable.Seq(LinkValue(uri, first +: more.toList))) + apply(Seq(LinkValue(uri, first +: more.toList))) def apply(firstValue: LinkValue, otherValues: LinkValue*): Link = apply(firstValue +: otherValues) implicit val valuesRenderer: Renderer[immutable.Iterable[LinkValue]] = Renderer.defaultSeqRenderer[LinkValue] // cache } -final case class Link(values: immutable.Seq[LinkValue]) extends jm.headers.Link with RequestResponseHeader { +final case class Link(values: Seq[LinkValue]) extends jm.headers.Link with RequestResponseHeader { import Link.valuesRenderer def renderValue[R <: Rendering](r: R): r.type = r ~~ values protected def companion = Link @@ -761,7 +761,7 @@ final case class Location(uri: Uri) extends jm.headers.Location with ResponseHea object Origin extends ModeledCompanion[Origin] { def apply(firstOrigin: HttpOrigin, otherOrigins: HttpOrigin*): Origin = apply(firstOrigin +: otherOrigins) } -final case class Origin(origins: immutable.Seq[HttpOrigin]) extends jm.headers.Origin with RequestHeader +final case class Origin(origins: Seq[HttpOrigin]) extends jm.headers.Origin with RequestHeader with SensitiveHttpHeader { def renderValue[R <: Rendering](r: R): r.type = if (origins.isEmpty) r ~~ "null" else r ~~ origins @@ -773,11 +773,11 @@ final case class Origin(origins: immutable.Seq[HttpOrigin]) extends jm.headers.O // https://tools.ietf.org/html/rfc7235#section-4.3 object `Proxy-Authenticate` extends ModeledCompanion[`Proxy-Authenticate`] { - def apply(first: HttpChallenge, more: HttpChallenge*): `Proxy-Authenticate` = apply(immutable.Seq(first +: more: _*)) + def apply(first: HttpChallenge, more: HttpChallenge*): `Proxy-Authenticate` = apply(Seq(first +: more: _*)) implicit val challengesRenderer: Renderer[immutable.Iterable[HttpChallenge]] = Renderer.defaultSeqRenderer[HttpChallenge] // cache } -final case class `Proxy-Authenticate`(challenges: immutable.Seq[HttpChallenge]) extends jm.headers.ProxyAuthenticate +final case class `Proxy-Authenticate`(challenges: Seq[HttpChallenge]) extends jm.headers.ProxyAuthenticate with ResponseHeader { require(challenges.nonEmpty, "challenges must not be empty") import `Proxy-Authenticate`.challengesRenderer @@ -798,11 +798,11 @@ final case class `Proxy-Authorization`(credentials: HttpCredentials) extends jm. // https://tools.ietf.org/html/rfc7233#section-3.1 object Range extends ModeledCompanion[Range] { - def apply(first: ByteRange, more: ByteRange*): Range = apply(immutable.Seq(first +: more: _*)) - def apply(ranges: immutable.Seq[ByteRange]): Range = Range(RangeUnits.Bytes, ranges) + def apply(first: ByteRange, more: ByteRange*): Range = apply(Seq(first +: more: _*)) + def apply(ranges: Seq[ByteRange]): Range = Range(RangeUnits.Bytes, ranges) implicit val rangesRenderer: Renderer[immutable.Iterable[ByteRange]] = Renderer.defaultSeqRenderer[ByteRange] // cache } -final case class Range(rangeUnit: RangeUnit, ranges: immutable.Seq[ByteRange]) extends jm.headers.Range +final case class Range(rangeUnit: RangeUnit, ranges: Seq[ByteRange]) extends jm.headers.Range with RequestHeader { require(ranges.nonEmpty, "ranges must not be empty") import Range.rangesRenderer @@ -911,7 +911,7 @@ private[http] object `Sec-WebSocket-Extensions` extends ModeledCompanion[`Sec-We * INTERNAL API */ @InternalApi -private[http] final case class `Sec-WebSocket-Extensions`(extensions: immutable.Seq[WebSocketExtension]) +private[http] final case class `Sec-WebSocket-Extensions`(extensions: Seq[WebSocketExtension]) extends RequestResponseHeader { require(extensions.nonEmpty, "Sec-WebSocket-Extensions.extensions must not be empty") import `Sec-WebSocket-Extensions`.extensionsRenderer @@ -960,7 +960,7 @@ private[http] object `Sec-WebSocket-Protocol` extends ModeledCompanion[`Sec-WebS * INTERNAL API */ @InternalApi -private[http] final case class `Sec-WebSocket-Protocol`(protocols: immutable.Seq[String]) +private[http] final case class `Sec-WebSocket-Protocol`(protocols: Seq[String]) extends jm.headers.SecWebSocketProtocol with RequestResponseHeader { require(protocols.nonEmpty, "Sec-WebSocket-Protocol.protocols must not be empty") import `Sec-WebSocket-Protocol`.protocolsRenderer @@ -984,7 +984,7 @@ private[http] object `Sec-WebSocket-Version` extends ModeledCompanion[`Sec-WebSo * INTERNAL API */ @InternalApi -private[http] final case class `Sec-WebSocket-Version`(versions: immutable.Seq[Int]) +private[http] final case class `Sec-WebSocket-Version`(versions: Seq[Int]) extends RequestResponseHeader { require(versions.nonEmpty, "Sec-WebSocket-Version.versions must not be empty") require(versions.forall(v => v >= 0 && v <= 255), @@ -998,11 +998,11 @@ private[http] final case class `Sec-WebSocket-Version`(versions: immutable.Seq[I // https://tools.ietf.org/html/rfc7231#section-7.4.2 object Server extends ModeledCompanion[Server] { def apply(products: String): Server = apply(ProductVersion.parseMultiple(products)) - def apply(first: ProductVersion, more: ProductVersion*): Server = apply(immutable.Seq(first +: more: _*)) + def apply(first: ProductVersion, more: ProductVersion*): Server = apply(Seq(first +: more: _*)) implicit val productsRenderer: Renderer[immutable.Iterable[ProductVersion]] = Renderer.seqRenderer[ProductVersion](separator = " ") // cache } -final case class Server(products: immutable.Seq[ProductVersion]) extends jm.headers.Server with ResponseHeader { +final case class Server(products: Seq[ProductVersion]) extends jm.headers.Server with ResponseHeader { require(products.nonEmpty, "products must not be empty") import Server.productsRenderer def renderValue[R <: Rendering](r: R): r.type = r ~~ products @@ -1049,10 +1049,10 @@ final case class `Set-Cookie`(cookie: HttpCookie) extends jm.headers.SetCookie w // https://tools.ietf.org/html/rfc7230#section-4.3 object TE extends ModeledCompanion[TE] { - def apply(first: TransferEncoding, more: TransferEncoding*): TE = apply(immutable.Seq(first +: more: _*)) + def apply(first: TransferEncoding, more: TransferEncoding*): TE = apply(Seq(first +: more: _*)) } -final case class TE(acceptableEncodings: immutable.Seq[TransferEncoding]) extends jm.headers.TE with RequestHeader { - def append(encodings: immutable.Seq[TransferEncoding]) = TE(this.acceptableEncodings ++ encodings) +final case class TE(acceptableEncodings: Seq[TransferEncoding]) extends jm.headers.TE with RequestHeader { + def append(encodings: Seq[TransferEncoding]) = TE(this.acceptableEncodings ++ encodings) def renderValue[R <: Rendering](r: R): r.type = r.~~(acceptableEncodings)(`Transfer-Encoding`.encodingsRenderer) protected def companion = TE @@ -1090,11 +1090,11 @@ final case class `Tls-Session-Info`(session: SSLSession) extends jm.headers.TlsS // https://tools.ietf.org/html/rfc7230#section-3.3.1 object `Transfer-Encoding` extends ModeledCompanion[`Transfer-Encoding`] { def apply(first: TransferEncoding, more: TransferEncoding*): `Transfer-Encoding` = - apply(immutable.Seq(first +: more: _*)) + apply(Seq(first +: more: _*)) implicit val encodingsRenderer: Renderer[immutable.Iterable[TransferEncoding]] = Renderer.defaultSeqRenderer[TransferEncoding] // cache } -final case class `Transfer-Encoding`(encodings: immutable.Seq[TransferEncoding]) extends jm.headers.TransferEncoding +final case class `Transfer-Encoding`(encodings: Seq[TransferEncoding]) extends jm.headers.TransferEncoding with RequestResponseHeader { require(encodings.nonEmpty, "encodings must not be empty") import `Transfer-Encoding`.encodingsRenderer @@ -1108,7 +1108,7 @@ final case class `Transfer-Encoding`(encodings: immutable.Seq[TransferEncoding]) case remaining => Some(`Transfer-Encoding`(remaining)) } } else Some(this) - def append(encodings: immutable.Seq[TransferEncoding]) = `Transfer-Encoding`(this.encodings ++ encodings) + def append(encodings: Seq[TransferEncoding]) = `Transfer-Encoding`(this.encodings ++ encodings) def renderValue[R <: Rendering](r: R): r.type = r ~~ encodings protected def companion = `Transfer-Encoding` @@ -1121,7 +1121,7 @@ object Upgrade extends ModeledCompanion[Upgrade] { implicit val protocolsRenderer: Renderer[immutable.Iterable[UpgradeProtocol]] = Renderer.defaultSeqRenderer[UpgradeProtocol] } -final case class Upgrade(protocols: immutable.Seq[UpgradeProtocol]) extends RequestResponseHeader { +final case class Upgrade(protocols: Seq[UpgradeProtocol]) extends RequestResponseHeader { import Upgrade.protocolsRenderer protected[http] def renderValue[R <: Rendering](r: R): r.type = r ~~ protocols @@ -1133,11 +1133,11 @@ final case class Upgrade(protocols: immutable.Seq[UpgradeProtocol]) extends Requ // https://tools.ietf.org/html/rfc7231#section-5.5.3 object `User-Agent` extends ModeledCompanion[`User-Agent`] { def apply(products: String): `User-Agent` = apply(ProductVersion.parseMultiple(products)) - def apply(first: ProductVersion, more: ProductVersion*): `User-Agent` = apply(immutable.Seq(first +: more: _*)) + def apply(first: ProductVersion, more: ProductVersion*): `User-Agent` = apply(Seq(first +: more: _*)) implicit val productsRenderer: Renderer[immutable.Iterable[ProductVersion]] = Renderer.seqRenderer[ProductVersion](separator = " ") // cache } -final case class `User-Agent`(products: immutable.Seq[ProductVersion]) extends jm.headers.UserAgent with RequestHeader { +final case class `User-Agent`(products: Seq[ProductVersion]) extends jm.headers.UserAgent with RequestHeader { require(products.nonEmpty, "products must not be empty") import `User-Agent`.productsRenderer def renderValue[R <: Rendering](r: R): r.type = r ~~ products @@ -1149,11 +1149,11 @@ final case class `User-Agent`(products: immutable.Seq[ProductVersion]) extends j // https://tools.ietf.org/html/rfc7235#section-4.1 object `WWW-Authenticate` extends ModeledCompanion[`WWW-Authenticate`] { - def apply(first: HttpChallenge, more: HttpChallenge*): `WWW-Authenticate` = apply(immutable.Seq(first +: more: _*)) + def apply(first: HttpChallenge, more: HttpChallenge*): `WWW-Authenticate` = apply(Seq(first +: more: _*)) implicit val challengesRenderer: Renderer[immutable.Iterable[HttpChallenge]] = Renderer.defaultSeqRenderer[HttpChallenge] // cache } -final case class `WWW-Authenticate`(challenges: immutable.Seq[HttpChallenge]) extends jm.headers.WWWAuthenticate +final case class `WWW-Authenticate`(challenges: Seq[HttpChallenge]) extends jm.headers.WWWAuthenticate with ResponseHeader { require(challenges.nonEmpty, "challenges must not be empty") import `WWW-Authenticate`.challengesRenderer @@ -1166,13 +1166,13 @@ final case class `WWW-Authenticate`(challenges: immutable.Seq[HttpChallenge]) ex // https://en.wikipedia.org/wiki/X-Forwarded-For object `X-Forwarded-For` extends ModeledCompanion[`X-Forwarded-For`] { - def apply(first: RemoteAddress, more: RemoteAddress*): `X-Forwarded-For` = apply(immutable.Seq(first +: more: _*)) + def apply(first: RemoteAddress, more: RemoteAddress*): `X-Forwarded-For` = apply(Seq(first +: more: _*)) implicit val addressesRenderer: Renderer[immutable.Iterable[RemoteAddress]] = { implicit val singleAddressRenderer = RemoteAddress.renderWithoutPort Renderer.defaultSeqRenderer[RemoteAddress] // cache } } -final case class `X-Forwarded-For`(addresses: immutable.Seq[RemoteAddress]) extends jm.headers.XForwardedFor +final case class `X-Forwarded-For`(addresses: Seq[RemoteAddress]) extends jm.headers.XForwardedFor with RequestHeader with SensitiveHttpHeader { require(addresses.nonEmpty, "addresses must not be empty") import `X-Forwarded-For`.addressesRenderer @@ -1234,7 +1234,7 @@ object Trailer extends ModeledCompanion[Trailer] { private implicit val trailersRenderer: Renderer[immutable.Iterable[String]] = Renderer.defaultSeqRenderer[String] - def apply(values: immutable.Seq[String]): Trailer = { + def apply(values: Seq[String]): Trailer = { val clean = values.map(_.trim).filter(_.nonEmpty) val (forbidden, allowed) = clean.partition(name => isForbidden(name.toRootLowerCase)) if (clean.isEmpty) @@ -1292,7 +1292,7 @@ object Trailer extends ModeledCompanion[Trailer] { * @since 1.3.0 */ @ApiMayChange -final case class Trailer private (values: immutable.Seq[String]) extends jm.headers.Trailer with RequestResponseHeader { +final case class Trailer private (values: Seq[String]) extends jm.headers.Trailer with RequestResponseHeader { require(values.nonEmpty, "Trailer values must not be empty") import Trailer.trailersRenderer def getTrailers: Iterable[String] = values.asJava diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/ws/WebSocketRequest.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/ws/WebSocketRequest.scala index c1cc56f8df..d8d36897ce 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/ws/WebSocketRequest.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/ws/WebSocketRequest.scala @@ -13,8 +13,6 @@ package org.apache.pekko.http.scaladsl.model.ws -import scala.collection.immutable - import org.apache.pekko.http.scaladsl.model.{ HttpHeader, Uri } /** @@ -25,7 +23,7 @@ import org.apache.pekko.http.scaladsl.model.{ HttpHeader, Uri } */ final case class WebSocketRequest( uri: Uri, - extraHeaders: immutable.Seq[HttpHeader] = Nil, + extraHeaders: Seq[HttpHeader] = Nil, subprotocol: Option[String] = None) object WebSocketRequest { implicit def fromTargetUri(uri: Uri): WebSocketRequest = WebSocketRequest(uri) @@ -33,8 +31,8 @@ object WebSocketRequest { def apply( uri: Uri, - extraHeaders: immutable.Seq[HttpHeader], - subprotocols: immutable.Seq[String]): WebSocketRequest = + extraHeaders: Seq[HttpHeader], + subprotocols: Seq[String]): WebSocketRequest = WebSocketRequest( uri, extraHeaders, diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/ws/WebSocketUpgrade.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/ws/WebSocketUpgrade.scala index 779e40d1d5..6fc2a306a7 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/ws/WebSocketUpgrade.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/ws/WebSocketUpgrade.scala @@ -15,7 +15,6 @@ package org.apache.pekko.http.scaladsl.model.ws import java.lang.Iterable import java.util.function.{ Predicate => JPredicate } -import scala.collection.immutable import org.apache.pekko import pekko.NotUsed import pekko.stream._ @@ -38,7 +37,7 @@ trait WebSocketUpgrade extends jm.ws.WebSocketUpgrade { * * See http://tools.ietf.org/html/rfc6455#section-1.9 */ - def requestedProtocols: immutable.Seq[String] + def requestedProtocols: Seq[String] /** * The high-level interface to create a WebSocket server based on "messages". diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ClientConnectionSettings.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ClientConnectionSettings.scala index 69c99aa3b1..ee586f01e7 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ClientConnectionSettings.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ClientConnectionSettings.scala @@ -27,7 +27,6 @@ import pekko.http.scaladsl.model.headers.`User-Agent` import pekko.io.Inet.SocketOption import com.typesafe.config.Config -import scala.collection.immutable import scala.concurrent.duration.{ Duration, FiniteDuration } /** @@ -43,7 +42,7 @@ abstract class ClientConnectionSettings private[pekko] () def requestHeaderSizeHint: Int def websocketSettings: WebSocketSettings def websocketRandomFactory: () => Random - def socketOptions: immutable.Seq[SocketOption] + def socketOptions: Seq[SocketOption] def parserSettings: ParserSettings def logUnencryptedNetworkBytes: Option[Int] def streamCancellationDelay: FiniteDuration @@ -73,7 +72,7 @@ abstract class ClientConnectionSettings private[pekko] () self.copy(userAgentHeader = newValue) def withLogUnencryptedNetworkBytes(newValue: Option[Int]): ClientConnectionSettings = self.copy(logUnencryptedNetworkBytes = newValue) - def withSocketOptions(newValue: immutable.Seq[SocketOption]): ClientConnectionSettings = + def withSocketOptions(newValue: Seq[SocketOption]): ClientConnectionSettings = self.copy(socketOptions = newValue) def withParserSettings(newValue: ParserSettings): ClientConnectionSettings = self.copy(parserSettings = newValue) def withLocalAddress(newValue: Option[InetSocketAddress]): ClientConnectionSettings = diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ConnectionPoolSettings.scala b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ConnectionPoolSettings.scala index 95439a3095..e6cc899675 100644 --- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ConnectionPoolSettings.scala +++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/ConnectionPoolSettings.scala @@ -20,7 +20,6 @@ import pekko.http.javadsl.{ settings => js } import pekko.http.scaladsl.ClientTransport import com.typesafe.config.Config -import scala.collection.immutable import scala.concurrent.duration.Duration import scala.concurrent.duration.FiniteDuration import scala.util.matching.Regex @@ -41,7 +40,7 @@ abstract class ConnectionPoolSettings extends js.ConnectionPoolSettings { self: def keepAliveTimeout: Duration def connectionSettings: ClientConnectionSettings def maxConnectionLifetime: Duration - private[pekko] def hostOverrides: immutable.Seq[(Regex, ConnectionPoolSettings)] + private[pekko] def hostOverrides: Seq[(Regex, ConnectionPoolSettings)] /** * This checks to see if there's a matching host override. When multiple patterns match, @@ -59,7 +58,7 @@ abstract class ConnectionPoolSettings extends js.ConnectionPoolSettings { self: // --- @ApiMayChange - def withHostOverrides(hostOverrides: immutable.Seq[(String, ConnectionPoolSettings)]): ConnectionPoolSettings = + def withHostOverrides(hostOverrides: Seq[(String, ConnectionPoolSettings)]): ConnectionPoolSettings = self.copy(hostOverrides = hostOverrides.map { case (h, s) => ConnectionPoolSettingsImpl.hostRegex(h) -> s }) @ApiMayChange 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 670eb002a5..0d1d95f628 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 @@ -26,7 +26,6 @@ import pekko.http.scaladsl.model.HttpResponse import pekko.http.scaladsl.model.headers.{ Host, Server } import pekko.io.Inet.SocketOption -import scala.collection.immutable import scala.concurrent.duration.{ Duration, FiniteDuration } import scala.jdk.CollectionConverters._ import scala.jdk.OptionConverters._ @@ -47,7 +46,7 @@ abstract class ServerSettings private[pekko] () extends pekko.http.javadsl.setti def verboseErrorMessages: Boolean def responseHeaderSizeHint: Int def backlog: Int - def socketOptions: immutable.Seq[SocketOption] + def socketOptions: Seq[SocketOption] def defaultHostHeader: Host def websocketSettings: WebSocketSettings def parserSettings: ParserSettings @@ -124,7 +123,7 @@ abstract class ServerSettings private[pekko] () extends pekko.http.javadsl.setti def withDefaultHostHeader(newValue: Host): ServerSettings = self.copy(defaultHostHeader = newValue) def withParserSettings(newValue: ParserSettings): ServerSettings = self.copy(parserSettings = newValue) def withWebsocketSettings(newValue: WebSocketSettings): ServerSettings = self.copy(websocketSettings = newValue) - def withSocketOptions(newValue: immutable.Seq[SocketOption]): ServerSettings = self.copy(socketOptions = newValue) + def withSocketOptions(newValue: Seq[SocketOption]): ServerSettings = self.copy(socketOptions = newValue) def withHttp2Settings(newValue: Http2ServerSettings): ServerSettings = copy(http2Settings = newValue) // Scala-only lenses diff --git a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/NewConnectionPoolSpec.scala b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/NewConnectionPoolSpec.scala index 3fa239923e..4945b9b670 100644 --- a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/NewConnectionPoolSpec.scala +++ b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/NewConnectionPoolSpec.scala @@ -46,7 +46,6 @@ import pekko.stream.testkit.{ TestPublisher, TestSubscriber } import pekko.testkit._ import pekko.util.ByteString -import scala.collection.immutable import scala.concurrent.{ Await, ExecutionContext, Future, Promise } import scala.concurrent.duration._ import scala.util.control.NonFatal @@ -429,7 +428,7 @@ class NewConnectionPoolSpec extends PekkoSpecWithMaterializer(""" val gatewayConnection = hcpMinConnection.poolId acceptIncomingConnection() - requestIn.sendNext(HttpRequest(uri = "/minimumslots/1", headers = immutable.Seq(close)) -> 42) + requestIn.sendNext(HttpRequest(uri = "/minimumslots/1", headers = Seq(close)) -> 42) responseOutSub.request(1) responseOut.expectNextN(1) @@ -451,7 +450,7 @@ class NewConnectionPoolSpec extends PekkoSpecWithMaterializer(""" (1 to 30).foreach { _ => // run a few requests (0 until minConnections).foreach { i => - requestIn.sendNext(HttpRequest(uri = s"/minimumslots/5/$i", headers = immutable.Seq(close)) -> 42) + requestIn.sendNext(HttpRequest(uri = s"/minimumslots/5/$i", headers = Seq(close)) -> 42) } responseOutSub.request(minConnections) responseOut.expectNextN(minConnections) diff --git a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/FramingSpec.scala b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/FramingSpec.scala index de593558ca..8860c4b749 100644 --- a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/FramingSpec.scala +++ b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/FramingSpec.scala @@ -13,7 +13,6 @@ package org.apache.pekko.http.impl.engine.ws -import scala.collection.immutable import scala.concurrent.duration._ import org.scalatest.matchers.Matcher import org.apache.pekko @@ -314,10 +313,10 @@ class FramingSpec extends PekkoSpecWithMaterializer { result } - private def parseToEvents(bytes: Seq[ByteString]): immutable.Seq[FrameEvent] = + private def parseToEvents(bytes: Seq[ByteString]): Seq[FrameEvent] = Source(bytes.toVector).via(FrameEventParser).runFold(Vector.empty[FrameEvent])(_ :+ _) .awaitResult(1.second.dilated) - private def renderToByteString(events: immutable.Seq[FrameEvent]): ByteString = + private def renderToByteString(events: Seq[FrameEvent]): ByteString = Source(events).via(newRenderer()).runFold(ByteString.empty)(_ ++ _) .awaitResult(1.second.dilated) diff --git a/http-core/src/test/scala/org/apache/pekko/http/impl/model/parser/HttpHeaderSpec.scala b/http-core/src/test/scala/org/apache/pekko/http/impl/model/parser/HttpHeaderSpec.scala index a7a8658be3..3ae6464641 100644 --- a/http-core/src/test/scala/org/apache/pekko/http/impl/model/parser/HttpHeaderSpec.scala +++ b/http-core/src/test/scala/org/apache/pekko/http/impl/model/parser/HttpHeaderSpec.scala @@ -15,8 +15,6 @@ package org.apache.pekko.http.impl.model.parser import java.net.InetAddress -import scala.collection.immutable.Seq - import org.apache.pekko import pekko.http.scaladsl.settings.ParserSettings.CookieParsingMode import pekko.http.impl.model.parser.HeaderParser.Settings diff --git a/http-core/src/test/scala/org/apache/pekko/http/javadsl/model/JavaApiTestCaseSpecs.scala b/http-core/src/test/scala/org/apache/pekko/http/javadsl/model/JavaApiTestCaseSpecs.scala index 887aeda986..78a50b7462 100644 --- a/http-core/src/test/scala/org/apache/pekko/http/javadsl/model/JavaApiTestCaseSpecs.scala +++ b/http-core/src/test/scala/org/apache/pekko/http/javadsl/model/JavaApiTestCaseSpecs.scala @@ -18,7 +18,6 @@ import pekko.http.javadsl.model.headers.Cookie import pekko.http.scaladsl.model import pekko.http.scaladsl.model.headers.BasicHttpCredentials -import scala.collection.immutable import org.scalatest.freespec.AnyFreeSpec import org.scalatest.matchers.must.Matchers @@ -52,11 +51,11 @@ class JavaApiTestCaseSpecs extends AnyFreeSpec with Matchers { } "addAuthentication" in { JavaApiTestCases.addAuthentication(model.HttpRequest()) must be( - model.HttpRequest(headers = immutable.Seq(model.headers.Authorization(BasicHttpCredentials("username", + model.HttpRequest(headers = Seq(model.headers.Authorization(BasicHttpCredentials("username", "password"))))) } "removeCookies" in { - val testRequest = model.HttpRequest(headers = immutable.Seq(Cookie.create("test", "blub"))) + val testRequest = model.HttpRequest(headers = Seq(Cookie.create("test", "blub"))) JavaApiTestCases.removeCookies(testRequest) must be( model.HttpRequest()) } diff --git a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/model/headers/HeaderSpec.scala b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/model/headers/HeaderSpec.scala index f5af11aff3..9527fb9d23 100644 --- a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/model/headers/HeaderSpec.scala +++ b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/model/headers/HeaderSpec.scala @@ -21,8 +21,6 @@ import pekko.http.scaladsl.model.{ headers, Trailer => _, _ } import org.scalatest.freespec.AnyFreeSpec import org.scalatest.matchers.should.Matchers -import scala.collection.immutable - class HeaderSpec extends AnyFreeSpec with Matchers { "ModeledCompanion should" - { "provide parseFromValueString method" - { @@ -193,7 +191,7 @@ class HeaderSpec extends AnyFreeSpec with Matchers { `X-Forwarded-Host`(Uri.Host(InetAddress.getByName("192.168.0.2"))), `X-Forwarded-Proto`("https"), `X-Real-Ip`(RemoteAddress(InetAddress.getByName("192.168.1.1"))), - Trailer(immutable.Seq("X-My-Trailer", "X-My-Other-Trailer"))) + Trailer(Seq("X-My-Trailer", "X-My-Other-Trailer"))) requestHeaders.foreach { header => header shouldBe Symbol("renderInRequests") @@ -238,7 +236,7 @@ class HeaderSpec extends AnyFreeSpec with Matchers { Upgrade(Vector(UpgradeProtocol("HTTP", Some("2.0")))), `WWW-Authenticate`(HttpChallenge("Basic", Some("example.com"))), `Retry-After`(120), - Trailer(immutable.Seq("X-My-Trailer", "X-My-Other-Trailer"))) + Trailer(Seq("X-My-Trailer", "X-My-Other-Trailer"))) responseHeaders.foreach { header => header shouldBe Symbol("renderInResponses") diff --git a/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/CorsDirectives.scala b/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/CorsDirectives.scala index 1c830189c7..18d1f5434c 100644 --- a/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/CorsDirectives.scala +++ b/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/CorsDirectives.scala @@ -17,8 +17,6 @@ package org.apache.pekko.http.cors.scaladsl -import scala.collection.immutable.Seq - import org.apache.pekko import pekko.http.cors.javadsl import pekko.http.cors.scaladsl.model.HttpOriginMatcher diff --git a/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/CorsRejection.scala b/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/CorsRejection.scala index 4f7d9ec560..c7a80784c9 100644 --- a/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/CorsRejection.scala +++ b/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/CorsRejection.scala @@ -19,7 +19,6 @@ package org.apache.pekko.http.cors.scaladsl import java.util -import scala.collection.immutable.Seq import scala.jdk.CollectionConverters._ import org.apache.pekko diff --git a/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/model/HttpHeaderRange.scala b/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/model/HttpHeaderRange.scala index fad2930d6b..556ba991d7 100644 --- a/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/model/HttpHeaderRange.scala +++ b/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/model/HttpHeaderRange.scala @@ -17,8 +17,6 @@ package org.apache.pekko.http.cors.scaladsl.model -import scala.collection.immutable.Seq - import org.apache.pekko import pekko.http.cors.CorsJavaMapping.Implicits._ import pekko.http.cors.javadsl diff --git a/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/model/HttpOriginMatcher.scala b/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/model/HttpOriginMatcher.scala index b3d5ac1abe..090bdd0bdc 100644 --- a/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/model/HttpOriginMatcher.scala +++ b/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/model/HttpOriginMatcher.scala @@ -17,8 +17,6 @@ package org.apache.pekko.http.cors.scaladsl.model -import scala.collection.immutable.Seq - import org.apache.pekko import pekko.http.cors.javadsl import pekko.http.javadsl.{ model => jm } diff --git a/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/settings/CorsSettings.scala b/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/settings/CorsSettings.scala index d5fa20a14a..8c5668777f 100644 --- a/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/settings/CorsSettings.scala +++ b/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/settings/CorsSettings.scala @@ -20,7 +20,6 @@ package org.apache.pekko.http.cors.scaladsl.settings import java.util.OptionalLong import java.util.concurrent.TimeUnit -import scala.collection.immutable.Seq import scala.jdk.CollectionConverters._ import scala.jdk.OptionConverters._ import scala.util.Try diff --git a/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/settings/CorsSettingsImpl.scala b/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/settings/CorsSettingsImpl.scala index efd5d3600f..25e27ccb44 100644 --- a/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/settings/CorsSettingsImpl.scala +++ b/http-cors/src/main/scala/org/apache/pekko/http/cors/scaladsl/settings/CorsSettingsImpl.scala @@ -17,8 +17,6 @@ package org.apache.pekko.http.cors.scaladsl.settings -import scala.collection.immutable.Seq - import org.apache.pekko import pekko.http.cors.scaladsl.model.{ HttpHeaderRange, HttpOriginMatcher } import pekko.http.scaladsl.model.{ HttpHeader, HttpMethod } diff --git a/http-cors/src/test/scala/org/apache/pekko/http/cors/CorsDirectivesSpec.scala b/http-cors/src/test/scala/org/apache/pekko/http/cors/CorsDirectivesSpec.scala index b75ddd83f8..61fedc9879 100644 --- a/http-cors/src/test/scala/org/apache/pekko/http/cors/CorsDirectivesSpec.scala +++ b/http-cors/src/test/scala/org/apache/pekko/http/cors/CorsDirectivesSpec.scala @@ -17,8 +17,6 @@ package org.apache.pekko.http.cors -import scala.collection.immutable.Seq - import org.apache.pekko import pekko.http.cors.scaladsl.CorsRejection import pekko.http.cors.scaladsl.model.{ HttpHeaderRange, HttpOriginMatcher } diff --git a/http-marshallers-scala/http-xml/src/main/scala/org/apache/pekko/http/scaladsl/marshallers/xml/ScalaXmlSupport.scala b/http-marshallers-scala/http-xml/src/main/scala/org/apache/pekko/http/scaladsl/marshallers/xml/ScalaXmlSupport.scala index 6d7dc8b1c5..475ba3ba7f 100644 --- a/http-marshallers-scala/http-xml/src/main/scala/org/apache/pekko/http/scaladsl/marshallers/xml/ScalaXmlSupport.scala +++ b/http-marshallers-scala/http-xml/src/main/scala/org/apache/pekko/http/scaladsl/marshallers/xml/ScalaXmlSupport.scala @@ -16,7 +16,6 @@ package org.apache.pekko.http.scaladsl.marshallers.xml import java.io.{ ByteArrayInputStream, InputStreamReader } import javax.xml.parsers.{ SAXParser, SAXParserFactory } -import scala.collection.immutable import scala.xml.{ NodeSeq, XML } import org.apache.pekko @@ -50,9 +49,9 @@ trait ScalaXmlSupport { protected def createSAXParser(): SAXParser = ScalaXmlSupport.createSaferSAXParser() } object ScalaXmlSupport extends ScalaXmlSupport { - val nodeSeqMediaTypes: immutable.Seq[MediaType.NonBinary] = + val nodeSeqMediaTypes: Seq[MediaType.NonBinary] = List(`text/xml`, `application/xml`, `text/html`, `application/xhtml+xml`) - val nodeSeqContentTypeRanges: immutable.Seq[ContentTypeRange] = nodeSeqMediaTypes.map(ContentTypeRange(_)) + val nodeSeqContentTypeRanges: Seq[ContentTypeRange] = nodeSeqMediaTypes.map(ContentTypeRange(_)) /** Creates a safer SAXParser. */ def createSaferSAXParser(): SAXParser = { diff --git a/http-testkit/src/main/scala/org/apache/pekko/http/scaladsl/testkit/RouteTest.scala b/http-testkit/src/main/scala/org/apache/pekko/http/scaladsl/testkit/RouteTest.scala index 38d85309df..dd5ec9ee15 100644 --- a/http-testkit/src/main/scala/org/apache/pekko/http/scaladsl/testkit/RouteTest.scala +++ b/http-testkit/src/main/scala/org/apache/pekko/http/scaladsl/testkit/RouteTest.scala @@ -13,7 +13,6 @@ package org.apache.pekko.http.scaladsl.testkit -import scala.collection.immutable import scala.concurrent.{ Await, ExecutionContext, ExecutionContextExecutor, Future } import scala.concurrent.duration._ import scala.reflect.ClassTag @@ -79,7 +78,7 @@ trait RouteTest extends RequestBuilding with WSTestRequestBuilding with RouteTes def response: HttpResponse = result.response def responseEntity: HttpEntity = result.entity private def rawResponse: HttpResponse = result.rawResponse - def chunks: immutable.Seq[HttpEntity.ChunkStreamPart] = result.chunks + def chunks: Seq[HttpEntity.ChunkStreamPart] = result.chunks def chunksStream: Source[ChunkStreamPart, Any] = result.chunksStream def entityAs[T: FromEntityUnmarshaller: ClassTag](implicit timeout: Duration = 1.second): T = { def msg(e: Throwable) = @@ -95,7 +94,7 @@ trait RouteTest extends RequestBuilding with WSTestRequestBuilding with RouteTes def mediaType: MediaType = contentType.mediaType def charsetOption: Option[HttpCharset] = contentType.charsetOption def charset: HttpCharset = charsetOption.getOrElse(sys.error("Binary entity does not have charset")) - def headers: immutable.Seq[HttpHeader] = rawResponse.headers + def headers: Seq[HttpHeader] = rawResponse.headers def header[T >: Null <: HttpHeader: ClassTag]: Option[T] = rawResponse.header[T](implicitly[ClassTag[T]]) def header(name: String): Option[HttpHeader] = rawResponse.headers.find(_.is(toRootLowerCase(name))) def status: StatusCode = rawResponse.status @@ -104,12 +103,12 @@ trait RouteTest extends RequestBuilding with WSTestRequestBuilding with RouteTes case Some(HttpEntity.LastChunk(extension, _)) => extension case _ => "" } - def trailer: immutable.Seq[HttpHeader] = chunks.lastOption match { + def trailer: Seq[HttpHeader] = chunks.lastOption match { case Some(HttpEntity.LastChunk(_, trailer)) => trailer case _ => Nil } - def rejections: immutable.Seq[Rejection] = result.rejections + def rejections: Seq[Rejection] = result.rejections def rejection: Rejection = { val r = rejections if (r.size == 1) r.head else failTest("Expected a single rejection but got %s (%s)".format(r.size, r)) diff --git a/http-testkit/src/main/scala/org/apache/pekko/http/scaladsl/testkit/RouteTestResultComponent.scala b/http-testkit/src/main/scala/org/apache/pekko/http/scaladsl/testkit/RouteTestResultComponent.scala index 82e3349068..4f27e0b3e4 100644 --- a/http-testkit/src/main/scala/org/apache/pekko/http/scaladsl/testkit/RouteTestResultComponent.scala +++ b/http-testkit/src/main/scala/org/apache/pekko/http/scaladsl/testkit/RouteTestResultComponent.scala @@ -15,7 +15,6 @@ package org.apache.pekko.http.scaladsl.testkit import java.util.concurrent.CountDownLatch -import scala.collection.immutable import scala.concurrent.duration._ import org.apache.pekko @@ -34,12 +33,12 @@ trait RouteTestResultComponent { * A receptacle for the response or rejections created by a route. */ class RouteTestResult(timeout: FiniteDuration)(implicit fm: Materializer) { - private var result: Option[Either[immutable.Seq[Rejection], HttpResponse]] = None + private var result: Option[Either[Seq[Rejection], HttpResponse]] = None private val latch = new CountDownLatch(1) def handled: Boolean = synchronized { result.isDefined && result.get.isRight } - def rejections: immutable.Seq[Rejection] = synchronized { + def rejections: Seq[Rejection] = synchronized { result match { case Some(Left(rejections)) => rejections case Some(Right(response)) => failTest("Request was not rejected, response was " + response) @@ -52,7 +51,7 @@ trait RouteTestResultComponent { /** Returns a "fresh" entity with a "fresh" unconsumed byte- or chunk stream (if not strict) */ def entity: ResponseEntity = entityRecreator() - def chunks: immutable.Seq[ChunkStreamPart] = + def chunks: Seq[ChunkStreamPart] = entity match { case HttpEntity.Chunked(_, chunks) => awaitAllElements[ChunkStreamPart](chunks) case _ => Nil @@ -118,7 +117,7 @@ trait RouteTestResultComponent { private def failNeitherCompletedNorRejected(): Nothing = failTest("Request was neither completed nor rejected within " + timeout) - private def awaitAllElements[T](data: Source[T, ?]): immutable.Seq[T] = + private def awaitAllElements[T](data: Source[T, ?]): Seq[T] = data.limit(100000).runWith(Sink.seq).awaitResult(timeout) } } diff --git a/http-testkit/src/main/scala/org/apache/pekko/http/scaladsl/testkit/WSTestRequestBuilding.scala b/http-testkit/src/main/scala/org/apache/pekko/http/scaladsl/testkit/WSTestRequestBuilding.scala index e510ec2a62..b1bab2a60a 100644 --- a/http-testkit/src/main/scala/org/apache/pekko/http/scaladsl/testkit/WSTestRequestBuilding.scala +++ b/http-testkit/src/main/scala/org/apache/pekko/http/scaladsl/testkit/WSTestRequestBuilding.scala @@ -13,8 +13,6 @@ package org.apache.pekko.http.scaladsl.testkit -import scala.collection.immutable - import org.apache.pekko import pekko.http.impl.engine.server.InternalCustomHeader import pekko.http.scaladsl.model.{ HttpRequest, HttpResponse, StatusCodes, Uri } @@ -29,7 +27,7 @@ trait WSTestRequestBuilding { implicit materializer: Materializer): HttpRequest = { val upgrade = new InternalCustomHeader("UpgradeToWebSocketTestHeader") with WebSocketUpgrade { - def requestedProtocols: immutable.Seq[String] = subprotocols.toList + def requestedProtocols: Seq[String] = subprotocols.toList def handleMessages( handlerFlow: Graph[FlowShape[Message, Message], Any], subprotocol: Option[String]): HttpResponse = { diff --git a/http-tests/src/multi-jvm/scala/org/apache/pekko/remote/testkit/MultiNodeConfig.scala b/http-tests/src/multi-jvm/scala/org/apache/pekko/remote/testkit/MultiNodeConfig.scala index 052a875d44..1a024db9ad 100644 --- a/http-tests/src/multi-jvm/scala/org/apache/pekko/remote/testkit/MultiNodeConfig.scala +++ b/http-tests/src/multi-jvm/scala/org/apache/pekko/remote/testkit/MultiNodeConfig.scala @@ -19,7 +19,6 @@ import com.typesafe.config.{ Config, ConfigFactory, ConfigObject } import scala.concurrent.{ Await, Awaitable } import scala.concurrent.duration._ -import scala.collection.immutable import scala.util.control.NonFatal import org.apache.pekko @@ -38,7 +37,7 @@ abstract class MultiNodeConfig { private var _commonConf: Option[Config] = None private var _nodeConf = Map[RoleName, Config]() private var _roles = Vector[RoleName]() - private var _deployments = Map[RoleName, immutable.Seq[String]]() + private var _deployments = Map[RoleName, Seq[String]]() private var _allDeploy = Vector[String]() private var _testTransport = false @@ -124,10 +123,10 @@ abstract class MultiNodeConfig { configs.reduceLeft(_ withFallback _) } - private[testkit] def deployments(node: RoleName): immutable.Seq[String] = + private[testkit] def deployments(node: RoleName): Seq[String] = (_deployments.get(node).getOrElse(Nil)) ++ _allDeploy - private[testkit] def roles: immutable.Seq[RoleName] = _roles + private[testkit] def roles: Seq[RoleName] = _roles } @@ -261,7 +260,7 @@ object MultiNodeSpec { * `AskTimeoutException: sending to terminated ref breaks promises`. Using lazy * val is fine. */ -abstract class MultiNodeSpec(val myself: RoleName, _system: ActorSystem, _roles: immutable.Seq[RoleName], +abstract class MultiNodeSpec(val myself: RoleName, _system: ActorSystem, _roles: Seq[RoleName], deployments: RoleName => Seq[String]) extends TestKit(_system) with MultiNodeSpecCallbacks { @@ -328,7 +327,7 @@ abstract class MultiNodeSpec(val myself: RoleName, _system: ActorSystem, _roles: /** * All registered roles */ - def roles: immutable.Seq[RoleName] = _roles + def roles: Seq[RoleName] = _roles /** * TO BE DEFINED BY USER: Defines the number of participants required for starting the test. This @@ -373,7 +372,7 @@ abstract class MultiNodeSpec(val myself: RoleName, _system: ActorSystem, _roles: def enterBarrier(name: String*): Unit = testConductor.enter( Timeout.durationToTimeout(remainingOr(testConductor.Settings.BarrierTimeout.duration)), - name.to(immutable.Seq)) + name.to(Seq)) /** * Query the controller for the transport address of the given node (by role name) and diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/marshalling/MarshallingSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/marshalling/MarshallingSpec.scala index 70af526745..f3e34dd1ed 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/marshalling/MarshallingSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/marshalling/MarshallingSpec.scala @@ -94,7 +94,7 @@ class MarshallingSpec extends AnyFreeSpec with Matchers with BeforeAndAfterAll w marshalToResponseForRequestAccepting(StatusCodes.EnhanceYourCalm, MediaTypes.`application/json`) shouldEqual HttpResponse(StatusCodes.EnhanceYourCalm, entity = HttpEntity(StatusCodes.EnhanceYourCalm.defaultMessage)) } - val headers: immutable.Seq[HttpHeader] = RawHeader("X-Test", "test") :: Nil + val headers: Seq[HttpHeader] = RawHeader("X-Test", "test") :: Nil "fromStatusCodeAndHeaders should properly marshal for a status code that doesn't allow an entity" in { marshalToResponse(StatusCodes.NoContent -> headers) shouldEqual HttpResponse(StatusCodes.NoContent, headers = headers, entity = HttpEntity.Empty) diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/SizeLimitSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/SizeLimitSpec.scala index 1cc0006d0e..56b6304eba 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/SizeLimitSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/SizeLimitSpec.scala @@ -13,7 +13,6 @@ package org.apache.pekko.http.scaladsl.server -import scala.collection.immutable import scala.concurrent.Await import scala.concurrent.duration.DurationInt @@ -109,7 +108,7 @@ class SizeLimitSpec extends AnyWordSpec with Matchers with RequestBuilding with val request = HttpRequest( HttpMethods.POST, s"http:/${binding.localAddress}/noDirective", - immutable.Seq(`Content-Encoding`(HttpEncodings.gzip)), + Seq(`Content-Encoding`(HttpEncodings.gzip)), HttpEntity(ContentTypes.`text/plain(UTF-8)`, zippedData)) zippedData.size should be <= maxContentLength @@ -193,7 +192,7 @@ class SizeLimitSpec extends AnyWordSpec with Matchers with RequestBuilding with val request = HttpRequest( HttpMethods.POST, s"http:/${binding.localAddress}/noDirective", - immutable.Seq(`Content-Encoding`(HttpEncodings.gzip)), + Seq(`Content-Encoding`(HttpEncodings.gzip)), HttpEntity(ContentTypes.`text/plain(UTF-8)`, zippedData)) zippedData.size should be <= maxContentLength @@ -212,7 +211,7 @@ class SizeLimitSpec extends AnyWordSpec with Matchers with RequestBuilding with val request = HttpRequest( HttpMethods.POST, s"http:/${binding.localAddress}/noDirective", - immutable.Seq(`Content-Encoding`(HttpEncodings.gzip)), + Seq(`Content-Encoding`(HttpEncodings.gzip)), HttpEntity(ContentTypes.`text/plain(UTF-8)`, zippedData)) zippedData.size should be > maxContentLength diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/WebSocketDirectivesSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/WebSocketDirectivesSpec.scala index 58f6c4da9d..1ad7d4e135 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/WebSocketDirectivesSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/WebSocketDirectivesSpec.scala @@ -15,8 +15,6 @@ package org.apache.pekko.http.scaladsl.server.directives import java.util.function.Predicate -import scala.collection.immutable - import org.apache.pekko import pekko.http.impl.engine.server.InternalCustomHeader import pekko.http.scaladsl.model.AttributeKeys.webSocketUpgrade @@ -91,7 +89,7 @@ class WebSocketDirectivesSpec extends RoutingSpec { request ~> javaRoute.asScala ~> check { isWebSocketUpgrade shouldEqual true - header[`Sec-WebSocket-Protocol`].get.protocols shouldEqual immutable.Seq("echo") + header[`Sec-WebSocket-Protocol`].get.protocols shouldEqual Seq("echo") } selectedSubprotocol shouldEqual Some(Some("echo")) @@ -166,7 +164,7 @@ class WebSocketDirectivesSpec extends RoutingSpec { onHandle: (Option[String], Message => Boolean) => Unit): HttpRequest = { val upgrade = new InternalCustomHeader("UpgradeToWebSocketTestHeader") with WebSocketUpgrade { - override def requestedProtocols: immutable.Seq[String] = offeredProtocols.toList + override def requestedProtocols: Seq[String] = offeredProtocols.toList override def handleMessages( handlerFlow: Graph[FlowShape[Message, Message], Any], diff --git a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/unmarshalling/sse/EventStreamUnmarshallingSpec.scala b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/unmarshalling/sse/EventStreamUnmarshallingSpec.scala index a8cf7d5a3f..355861c32c 100644 --- a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/unmarshalling/sse/EventStreamUnmarshallingSpec.scala +++ b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/unmarshalling/sse/EventStreamUnmarshallingSpec.scala @@ -18,8 +18,6 @@ package sse import java.util.{ List => JList } -import scala.collection.immutable.Seq - import org.apache.pekko import pekko.NotUsed import pekko.http.scaladsl.model.HttpEntity diff --git a/http/src/main/scala/org/apache/pekko/http/javadsl/server/RejectionHandler.scala b/http/src/main/scala/org/apache/pekko/http/javadsl/server/RejectionHandler.scala index fcc650e438..244a85f983 100644 --- a/http/src/main/scala/org/apache/pekko/http/javadsl/server/RejectionHandler.scala +++ b/http/src/main/scala/org/apache/pekko/http/javadsl/server/RejectionHandler.scala @@ -69,7 +69,7 @@ class RejectionHandlerBuilder(asScala: server.RejectionHandler.Builder) { */ def handleAll[T <: Rejection]( t: Class[T], handler: function.Function[java.util.List[T], Route]): RejectionHandlerBuilder = { - asScala.handleAll { (rejections: collection.immutable.Seq[T]) => handler.apply(rejections.asJava).delegate }( + asScala.handleAll { (rejections: Seq[T]) => handler.apply(rejections.asJava).delegate }( ClassTag(t)) this } diff --git a/http/src/main/scala/org/apache/pekko/http/javadsl/server/RoutingJavaMapping.scala b/http/src/main/scala/org/apache/pekko/http/javadsl/server/RoutingJavaMapping.scala index a48a8cd436..8b6fdeeda7 100644 --- a/http/src/main/scala/org/apache/pekko/http/javadsl/server/RoutingJavaMapping.scala +++ b/http/src/main/scala/org/apache/pekko/http/javadsl/server/RoutingJavaMapping.scala @@ -15,8 +15,6 @@ package org.apache.pekko.http.javadsl.server import java.util.concurrent.CompletionStage -import scala.collection.immutable - import org.apache.pekko import pekko.annotation.InternalApi import pekko.http.{ javadsl, scaladsl } @@ -35,7 +33,7 @@ private[http] object RoutingJavaMapping { object Implicits { implicit def convertToScala[J](j: J)(implicit mapping: J2SMapping[J]): mapping.S = mapping.toScala(j) - implicit def convertSeqToScala[J](j: Seq[J])(implicit mapping: J2SMapping[J]): immutable.Seq[mapping.S] = + implicit def convertSeqToScala[J](j: Seq[J])(implicit mapping: J2SMapping[J]): Seq[mapping.S] = j.map(mapping.toScala(_)).toList implicit def AddAsScala[J](javaObject: J)(implicit mapping: J2SMapping[J]): AsScala[mapping.S] = diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/client/RequestBuilding.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/client/RequestBuilding.scala index bfce49f398..0eba329ccb 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/client/RequestBuilding.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/client/RequestBuilding.scala @@ -13,7 +13,6 @@ package org.apache.pekko.http.scaladsl.client -import scala.collection.immutable import scala.concurrent.{ Await, ExecutionContext } import scala.concurrent.duration._ import scala.reflect.ClassTag @@ -86,7 +85,7 @@ trait RequestBuilding extends TransformerPipelineSupport { def addHeaders(first: HttpHeader, more: HttpHeader*): RequestTransformer = _.mapHeaders(_ ++ (first +: more)) - def mapHeaders(f: immutable.Seq[HttpHeader] => immutable.Seq[HttpHeader]): RequestTransformer = _.mapHeaders(f) + def mapHeaders(f: Seq[HttpHeader] => Seq[HttpHeader]): RequestTransformer = _.mapHeaders(f) def removeHeader(headerName: String): RequestTransformer = _.mapHeaders(_.filterNot(_.name.equalsIgnoreCase(headerName))) diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Coders.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Coders.scala index 50a2ca0b73..daf93477c6 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Coders.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/coding/Coders.scala @@ -14,7 +14,6 @@ package org.apache.pekko.http.scaladsl.coding import scala.annotation.nowarn -import scala.collection.immutable import org.apache.pekko import pekko.http.scaladsl.model.HttpMessage @@ -35,5 +34,5 @@ object Coders { def NoCoding: Coder = pekko.http.scaladsl.coding.NoCoding - val DefaultCoders: immutable.Seq[Coder] = immutable.Seq(Gzip, Deflate, NoCoding) + val DefaultCoders: Seq[Coder] = Seq(Gzip, Deflate, NoCoding) } diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/common/StrictForm.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/common/StrictForm.scala index 2d469b5b60..516b1fd8b4 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/common/StrictForm.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/common/StrictForm.scala @@ -47,7 +47,7 @@ import pekko.stream.Materializer * }}} */ sealed abstract class StrictForm { - def fields: immutable.Seq[(String, StrictForm.Field)] + def fields: Seq[(String, StrictForm.Field)] def field(name: String): Option[StrictForm.Field] = fields.collectFirst { case (`name`, field) => field } } diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/marshalling/ContentTypeOverrider.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/marshalling/ContentTypeOverrider.scala index 5b8c3ca771..d955a02e41 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/marshalling/ContentTypeOverrider.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/marshalling/ContentTypeOverrider.scala @@ -13,8 +13,6 @@ package org.apache.pekko.http.scaladsl.marshalling -import scala.collection.immutable - import org.apache.pekko.http.scaladsl.model._ sealed trait ContentTypeOverrider[T] { @@ -28,9 +26,9 @@ object ContentTypeOverrider { value.withContentType(newContentType).asInstanceOf[T] // can't be expressed in types } - implicit def forHeadersAndEntity[T <: HttpEntity]: ContentTypeOverrider[(immutable.Seq[HttpHeader], T)] = - new ContentTypeOverrider[(immutable.Seq[HttpHeader], T)] { - def apply(value: (immutable.Seq[HttpHeader], T), newContentType: ContentType) = + implicit def forHeadersAndEntity[T <: HttpEntity]: ContentTypeOverrider[(Seq[HttpHeader], T)] = + new ContentTypeOverrider[(Seq[HttpHeader], T)] { + def apply(value: (Seq[HttpHeader], T), newContentType: ContentType) = value._1 -> value._2.withContentType(newContentType).asInstanceOf[T] } diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/marshalling/EmptyValue.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/marshalling/EmptyValue.scala index b4ef3fdfd7..a2be59cba7 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/marshalling/EmptyValue.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/marshalling/EmptyValue.scala @@ -13,8 +13,6 @@ package org.apache.pekko.http.scaladsl.marshalling -import scala.collection.immutable - import org.apache.pekko.http.scaladsl.model._ class EmptyValue[+T] private (val emptyValue: T) @@ -23,8 +21,8 @@ object EmptyValue { implicit def emptyEntity: EmptyValue[UniversalEntity] = new EmptyValue[UniversalEntity](HttpEntity.Empty) - implicit val emptyHeadersAndEntity: EmptyValue[(immutable.Seq[HttpHeader], UniversalEntity)] = - new EmptyValue[(immutable.Seq[HttpHeader], UniversalEntity)](Nil -> HttpEntity.Empty) + implicit val emptyHeadersAndEntity: EmptyValue[(Seq[HttpHeader], UniversalEntity)] = + new EmptyValue[(Seq[HttpHeader], UniversalEntity)](Nil -> HttpEntity.Empty) implicit val emptyResponse: EmptyValue[HttpResponse] = new EmptyValue[HttpResponse](HttpResponse(entity = emptyEntity.emptyValue)) diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/marshalling/PredefinedToRequestMarshallers.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/marshalling/PredefinedToRequestMarshallers.scala index e4bad7fb61..f3427cf50c 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/marshalling/PredefinedToRequestMarshallers.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/marshalling/PredefinedToRequestMarshallers.scala @@ -13,8 +13,6 @@ package org.apache.pekko.http.scaladsl.marshalling -import scala.collection.immutable - import org.apache.pekko import pekko.http.scaladsl.model._ import pekko.http.scaladsl.util.FastFuture._ @@ -31,7 +29,7 @@ trait PredefinedToRequestMarshallers { fromMethodAndUriAndHeadersAndValue[T].compose { case (m, u, v) => (m, u, Nil, v) } implicit def fromMethodAndUriAndHeadersAndValue[T]( - implicit mt: ToEntityMarshaller[T]): TRM[(HttpMethod, Uri, immutable.Seq[HttpHeader], T)] = + implicit mt: ToEntityMarshaller[T]): TRM[(HttpMethod, Uri, Seq[HttpHeader], T)] = Marshaller(implicit ec => { case (m, u, h, v) => mt(v).fast.map(_.map(_.map(HttpRequest(m, u, h, _)))) }) diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/marshalling/PredefinedToResponseMarshallers.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/marshalling/PredefinedToResponseMarshallers.scala index 8f4ffc6981..906b4f78c7 100755 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/marshalling/PredefinedToResponseMarshallers.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/marshalling/PredefinedToResponseMarshallers.scala @@ -13,7 +13,6 @@ package org.apache.pekko.http.scaladsl.marshalling -import scala.collection.immutable import scala.reflect.ClassTag import org.apache.pekko @@ -34,7 +33,7 @@ trait PredefinedToResponseMarshallers extends LowPriorityToResponseMarshallerImp def fromToEntityMarshaller[T]( status: StatusCode = StatusCodes.OK, - headers: immutable.Seq[HttpHeader] = Nil)( + headers: Seq[HttpHeader] = Nil)( implicit m: ToEntityMarshaller[T]): ToResponseMarshaller[T] = fromStatusCodeAndHeadersAndValue.compose(t => (status, headers, t)) @@ -54,18 +53,18 @@ trait PredefinedToResponseMarshallers extends LowPriorityToResponseMarshallerImp * a response either with a `text-plain` entity containing the `status.defaultMessage` or an empty entity * for status codes that don't allow a response. */ - implicit val fromStatusCodeAndHeaders: TRM[(StatusCode, immutable.Seq[HttpHeader])] = + implicit val fromStatusCodeAndHeaders: TRM[(StatusCode, Seq[HttpHeader])] = Marshaller.opaque { case (status, headers) => statusCodeResponse(status, headers) } implicit def fromStatusCodeAndValue[S, T](implicit sConv: S => StatusCode, mt: ToEntityMarshaller[T]): TRM[(S, T)] = fromStatusCodeAndHeadersAndValue[T].compose { case (status, value) => (sConv(status), Nil, value) } implicit def fromStatusCodeConvertibleAndHeadersAndT[S, T]( - implicit sConv: S => StatusCode, mt: ToEntityMarshaller[T]): TRM[(S, immutable.Seq[HttpHeader], T)] = + implicit sConv: S => StatusCode, mt: ToEntityMarshaller[T]): TRM[(S, Seq[HttpHeader], T)] = fromStatusCodeAndHeadersAndValue[T].compose { case (status, headers, value) => (sConv(status), headers, value) } implicit def fromStatusCodeAndHeadersAndValue[T]( - implicit mt: ToEntityMarshaller[T]): TRM[(StatusCode, immutable.Seq[HttpHeader], T)] = + implicit mt: ToEntityMarshaller[T]): TRM[(StatusCode, Seq[HttpHeader], T)] = Marshaller(implicit ec => { case (status, headers, value) => mt(value).fast.map { marshallings => @@ -145,7 +144,7 @@ object PredefinedToResponseMarshallers extends PredefinedToResponseMarshallers { /** INTERNAL API */ @InternalApi - private def statusCodeResponse(statusCode: StatusCode, headers: immutable.Seq[HttpHeader] = Nil): HttpResponse = { + private def statusCodeResponse(statusCode: StatusCode, headers: Seq[HttpHeader] = Nil): HttpResponse = { val entity = if (statusCode.allowsEntity) HttpEntity(statusCode.defaultMessage) else HttpEntity.Empty @@ -153,7 +152,7 @@ object PredefinedToResponseMarshallers extends PredefinedToResponseMarshallers { HttpResponse(status = statusCode, headers = headers, entity = entity) } - private def statusCodeAndEntityResponse(statusCode: StatusCode, headers: immutable.Seq[HttpHeader], + private def statusCodeAndEntityResponse(statusCode: StatusCode, headers: Seq[HttpHeader], entity: ResponseEntity): HttpResponse = { if (statusCode.allowsEntity) HttpResponse(statusCode, headers, entity) else HttpResponse(statusCode, headers, HttpEntity.Empty) diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/marshalling/package.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/marshalling/package.scala index a29c7e1940..edad86e1f0 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/marshalling/package.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/marshalling/package.scala @@ -13,8 +13,6 @@ package org.apache.pekko.http.scaladsl -import scala.collection.immutable - import org.apache.pekko import pekko.http.scaladsl.model._ import pekko.util.ByteString @@ -23,7 +21,7 @@ package object marshalling { // #marshaller-aliases type ToEntityMarshaller[T] = Marshaller[T, MessageEntity] type ToByteStringMarshaller[T] = Marshaller[T, ByteString] - type ToHeadersAndEntityMarshaller[T] = Marshaller[T, (immutable.Seq[HttpHeader], MessageEntity)] + type ToHeadersAndEntityMarshaller[T] = Marshaller[T, (Seq[HttpHeader], MessageEntity)] type ToResponseMarshaller[T] = Marshaller[T, HttpResponse] type ToRequestMarshaller[T] = Marshaller[T, HttpRequest] // #marshaller-aliases diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/Directive.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/Directive.scala index f20a7a5ab4..dcfd9cee20 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/Directive.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/Directive.scala @@ -13,7 +13,6 @@ package org.apache.pekko.http.scaladsl.server -import scala.collection.immutable import scala.concurrent.Future import org.apache.pekko @@ -142,7 +141,7 @@ abstract class Directive[L](implicit val ev: Tuple[L]) { * Creates a new directive that is able to recover from rejections that were produced by `this` Directive * **before the inner route was applied**. */ - def recover[R >: L](recovery: immutable.Seq[Rejection] => Directive[R])(implicit ev: Tuple[R]): Directive[R] = + def recover[R >: L](recovery: Seq[Rejection] => Directive[R])(implicit ev: Tuple[R]): Directive[R] = Directive[R] { inner => ctx => import ctx.executionContext @volatile var rejectedFromInnerRoute = false @@ -155,7 +154,7 @@ abstract class Directive[L](implicit val ev: Tuple[L]) { /** * Variant of `recover` that only recovers from rejections handled by the given PartialFunction. */ - def recoverPF[R >: L](recovery: PartialFunction[immutable.Seq[Rejection], Directive[R]])( + def recoverPF[R >: L](recovery: PartialFunction[Seq[Rejection], Directive[R]])( implicit ev: Tuple[R]): Directive[R] = recover { rejections => recovery.applyOrElse(rejections, (rejs: Seq[Rejection]) => RouteDirectives.reject(rejs: _*)) diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/Rejection.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/Rejection.scala index dbde2f99a8..43fa54062e 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/Rejection.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/Rejection.scala @@ -17,7 +17,6 @@ import java.lang.Iterable import java.util.Optional import java.util.function.Function -import scala.collection.immutable import scala.jdk.CollectionConverters._ import scala.jdk.OptionConverters._ import scala.runtime.AbstractFunction2 @@ -120,7 +119,7 @@ final case class MalformedHeaderRejection(headerName: String, errorMsg: String, * Rejection created by [[pekko.http.scaladsl.server.directives.HeaderDirectives.checkSameOrigin]]. * Signals that the request was rejected because `Origin` header value is invalid. */ -final case class InvalidOriginRejection(allowedOrigins: immutable.Seq[SHttpOrigin]) +final case class InvalidOriginRejection(allowedOrigins: Seq[SHttpOrigin]) extends jserver.InvalidOriginRejection with Rejection { override def getAllowedOrigins: java.util.List[JHttpOrigin] = allowedOrigins.map(_.asJava).asJava } @@ -173,7 +172,7 @@ final case class UnsupportedRequestEncodingRejection(supported: HttpEncoding) * Signals that the request was rejected because the requests contains only unsatisfiable ByteRanges. * The actualEntityLength gives the client a hint to create satisfiable ByteRanges. */ -final case class UnsatisfiableRangeRejection(unsatisfiableRanges: immutable.Seq[ByteRange], actualEntityLength: Long) +final case class UnsatisfiableRangeRejection(unsatisfiableRanges: Seq[ByteRange], actualEntityLength: Long) extends jserver.UnsatisfiableRangeRejection with Rejection { override def getUnsatisfiableRanges: Iterable[model.headers.ByteRange] = unsatisfiableRanges.map(_.asJava).asJava } @@ -308,7 +307,7 @@ final case class ValidationRejection(message: String, cause: Option[Throwable] = * MethodRejection added by the `get` directive is canceled by the `put` directive (since the HTTP method * did indeed match eventually). */ -final case class TransformationRejection(transform: immutable.Seq[Rejection] => immutable.Seq[Rejection]) +final case class TransformationRejection(transform: Seq[Rejection] => Seq[Rejection]) extends jserver.TransformationRejection with Rejection { override def getTransform = (t: Iterable[jserver.Rejection]) => { // explicit collects assignment is because of unidoc failing compilation on .asScala and .asJava here diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/RejectionHandler.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/RejectionHandler.scala index eaae59a0eb..6108e970de 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/RejectionHandler.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/RejectionHandler.scala @@ -25,7 +25,7 @@ import pekko.http.scaladsl.model.headers._ import pekko.http.scaladsl.server.AuthenticationFailedRejection._ import pekko.http.scaladsl.server.directives.BasicDirectives -trait RejectionHandler extends (immutable.Seq[Rejection] => Option[Route]) { self => +trait RejectionHandler extends (Seq[Rejection] => Option[Route]) { self => import RejectionHandler._ /** Map any HTTP response which was returned by this RejectionHandler to a different one before rendering it. */ @@ -52,7 +52,7 @@ trait RejectionHandler extends (immutable.Seq[Rejection] => Option[Route]) { sel case (a: BuiltRejectionHandler, b: BuiltRejectionHandler) => new BuiltRejectionHandler(a.cases ++ b.cases, a.notFound.orElse(b.notFound), b.isDefault) case _ => new RejectionHandler { - def apply(rejections: immutable.Seq[Rejection]): Option[Route] = + def apply(rejections: Seq[Rejection]): Option[Route] = self(rejections).orElse(that(rejections)) } } @@ -90,7 +90,7 @@ object RejectionHandler { * Handles several Rejections of the same type at the same time. * The seq passed to the given function is guaranteed to be non-empty. */ - def handleAll[T <: Rejection](f: immutable.Seq[T] => Route)(implicit ct: ClassTag[T]): this.type = { + def handleAll[T <: Rejection](f: Seq[T] => Route)(implicit ct: ClassTag[T]): this.type = { val runtimeClass = ct.runtimeClass cases += TypeHandler[T](runtimeClass, f) this @@ -126,7 +126,7 @@ object RejectionHandler { } } private final case class TypeHandler[T <: Rejection]( - runtimeClass: Class[?], f: immutable.Seq[T] => Route) extends Handler with PartialFunction[Rejection, T] { + runtimeClass: Class[?], f: Seq[T] => Route) extends Handler with PartialFunction[Rejection, T] { def isDefinedAt(rejection: Rejection): Boolean = runtimeClass.isInstance(rejection) def apply(rejection: Rejection): T = rejection.asInstanceOf[T] @@ -139,7 +139,7 @@ object RejectionHandler { val cases: Vector[Handler], val notFound: Option[Route], val isDefault: Boolean) extends RejectionHandler { - def apply(rejections: immutable.Seq[Rejection]): Option[Route] = + def apply(rejections: Seq[Rejection]): Option[Route] = if (rejections.nonEmpty) { @tailrec def rec(ix: Int): Option[Route] = if (ix < cases.length) { @@ -317,7 +317,7 @@ object RejectionHandler { * Filters out all TransformationRejections from the given sequence and applies them (in order) to the * remaining rejections. */ - def applyTransformations(rejections: immutable.Seq[Rejection]): immutable.Seq[Rejection] = { + def applyTransformations(rejections: Seq[Rejection]): Seq[Rejection] = { val (transformations, rest) = rejections.partition(_.isInstanceOf[TransformationRejection]) transformations.asInstanceOf[Seq[TransformationRejection]].foldLeft(rest.distinct) { case (remaining, transformation) => transformation.transform(remaining) diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/RouteResult.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/RouteResult.scala index 66c47a8518..e409d29a43 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/RouteResult.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/RouteResult.scala @@ -13,7 +13,6 @@ package org.apache.pekko.http.scaladsl.server -import scala.collection.immutable import scala.concurrent.Future import scala.jdk.CollectionConverters._ @@ -36,7 +35,7 @@ object RouteResult { final case class Complete(response: HttpResponse) extends javadsl.server.Complete with RouteResult { override def getResponse = response } - final case class Rejected(rejections: immutable.Seq[Rejection]) extends javadsl.server.Rejected with RouteResult { + final case class Rejected(rejections: Seq[Rejection]) extends javadsl.server.Rejected with RouteResult { override def getRejections = rejections.map(r => r: javadsl.server.Rejection).asJava } diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/BasicDirectives.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/BasicDirectives.scala index cb2e017113..6c65de6b29 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/BasicDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/BasicDirectives.scala @@ -16,7 +16,6 @@ package directives import java.util.concurrent.TimeoutException -import scala.collection.immutable import scala.concurrent.{ ExecutionContextExecutor, Future } import scala.concurrent.duration.FiniteDuration import scala.util.control.NonFatal @@ -99,19 +98,19 @@ trait BasicDirectives { /** * @group basic */ - def recoverRejections(f: immutable.Seq[Rejection] => RouteResult): Directive0 = + def recoverRejections(f: Seq[Rejection] => RouteResult): Directive0 = mapRouteResultPF { case RouteResult.Rejected(rejections) => f(rejections) } /** * @group basic */ - def recoverRejectionsWith(f: immutable.Seq[Rejection] => Future[RouteResult]): Directive0 = + def recoverRejectionsWith(f: Seq[Rejection] => Future[RouteResult]): Directive0 = mapRouteResultWithPF { case RouteResult.Rejected(rejections) => f(rejections) } /** * @group basic */ - def mapRejections(f: immutable.Seq[Rejection] => immutable.Seq[Rejection]): Directive0 = + def mapRejections(f: Seq[Rejection] => Seq[Rejection]): Directive0 = recoverRejections(rejections => RouteResult.Rejected(f(rejections))) /** @@ -129,7 +128,7 @@ trait BasicDirectives { /** * @group basic */ - def mapResponseHeaders(f: immutable.Seq[HttpHeader] => immutable.Seq[HttpHeader]): Directive0 = + def mapResponseHeaders(f: Seq[HttpHeader] => Seq[HttpHeader]): Directive0 = mapResponse(_.mapHeaders(f)) /** diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/CodingDirectives.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/CodingDirectives.scala index e5025c4b7f..989c7ceb5c 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/CodingDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/CodingDirectives.scala @@ -14,7 +14,6 @@ package org.apache.pekko.http.scaladsl.server package directives -import scala.collection.immutable import scala.util.control.NonFatal import org.apache.pekko @@ -75,7 +74,7 @@ trait CodingDirectives { * @group coding */ def encodeResponseWith(first: Encoder, more: Encoder*): Directive0 = - _encodeResponse(immutable.Seq(first +: more: _*)) + _encodeResponse(Seq(first +: more: _*)) // decoding @@ -154,17 +153,17 @@ trait CodingDirectives { } object CodingDirectives extends CodingDirectives { - def DefaultCoders: immutable.Seq[Coder] = Coders.DefaultCoders + def DefaultCoders: Seq[Coder] = Coders.DefaultCoders // same entries as DefaultCoders but in different order - private[http] val DefaultEncodeResponseEncoders = immutable.Seq(Coders.NoCoding, Coders.Gzip, Coders.Deflate) + private[http] val DefaultEncodeResponseEncoders = Seq(Coders.NoCoding, Coders.Gzip, Coders.Deflate) def theseOrDefault[T >: Coder](these: Seq[T]): Seq[T] = if (these.isEmpty) DefaultCoders else these import BasicDirectives._ import RouteDirectives._ - private def _encodeResponse(encoders: immutable.Seq[Encoder]): Directive0 = + private def _encodeResponse(encoders: Seq[Encoder]): Directive0 = BasicDirectives.extractRequest.flatMap { request => val negotiator = EncodingNegotiator(request.headers) val encodings: List[HttpEncoding] = encoders.map(_.encoding).toList diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/ExecutionDirectives.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/ExecutionDirectives.scala index 8e6c9a9d2b..14aaa2091a 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/ExecutionDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/ExecutionDirectives.scala @@ -14,7 +14,6 @@ package org.apache.pekko.http.scaladsl.server package directives -import scala.collection.immutable import scala.concurrent.Future import scala.util.control.NonFatal @@ -56,7 +55,7 @@ trait ExecutionDirectives { extractRequestContext.flatMap { ctx => val maxIterations = 8 // allow for up to `maxIterations` nested rejections from RejectionHandler before bailing out - def handle(rejections: immutable.Seq[Rejection], originalRejections: immutable.Seq[Rejection], + def handle(rejections: Seq[Rejection], originalRejections: Seq[Rejection], iterationsLeft: Int = maxIterations): Future[RouteResult] = if (iterationsLeft > 0) { handler(rejections) match { diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/FileUploadDirectives.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/FileUploadDirectives.scala index 0b50701564..b8ab91b87a 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/FileUploadDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/FileUploadDirectives.scala @@ -16,7 +16,6 @@ package org.apache.pekko.http.scaladsl.server.directives import java.io.File import java.nio.file.{ Files, Path } -import scala.collection.immutable import scala.concurrent.{ Future, Promise } import scala.util.{ Failure, Success } @@ -82,7 +81,7 @@ trait FileUploadDirectives { * @group fileupload */ @ApiMayChange - def storeUploadedFiles(fieldName: String, destFn: FileInfo => File): Directive1[immutable.Seq[(FileInfo, File)]] = + def storeUploadedFiles(fieldName: String, destFn: FileInfo => File): Directive1[Seq[(FileInfo, File)]] = entity(as[Multipart.FormData]).flatMap { formData => extractRequestContext.flatMap { ctx => implicit val mat = ctx.materializer @@ -171,7 +170,7 @@ trait FileUploadDirectives { * @group fileupload */ @ApiMayChange - def fileUploadAll(fieldName: String): Directive1[immutable.Seq[(FileInfo, Source[ByteString, Any])]] = + def fileUploadAll(fieldName: String): Directive1[Seq[(FileInfo, Source[ByteString, Any])]] = extractRequestContext.flatMap { ctx => implicit val ec = ctx.executionContext diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/FormFieldDirectives.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/FormFieldDirectives.scala index 9534cc7f3d..e6646aca94 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/FormFieldDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/FormFieldDirectives.scala @@ -55,12 +55,12 @@ trait FormFieldDirectives extends FormFieldDirectivesInstances with ToNameRecept * * @group form */ - def formFieldSeq: Directive1[immutable.Seq[(String, String)]] = _formFieldSeq + def formFieldSeq: Directive1[Seq[(String, String)]] = _formFieldSeq } object FormFieldDirectives extends FormFieldDirectives { - private val _formFieldSeq: Directive1[immutable.Seq[(String, String)]] = { + private val _formFieldSeq: Directive1[Seq[(String, String)]] = { import FutureDirectives._ import pekko.http.scaladsl.unmarshalling._ @@ -87,7 +87,7 @@ object FormFieldDirectives extends FormFieldDirectives { private val _formFieldMultiMap: Directive1[Map[String, List[String]]] = { @tailrec def append( map: Map[String, List[String]], - fields: immutable.Seq[(String, String)]): Map[String, List[String]] = { + fields: Seq[(String, String)]): Map[String, List[String]] = { if (fields.isEmpty) { map } else { diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/ParameterDirectives.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/ParameterDirectives.scala index bde69c4f87..8f718e25c4 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/ParameterDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/ParameterDirectives.scala @@ -14,7 +14,6 @@ package org.apache.pekko.http.scaladsl.server package directives -import scala.collection.immutable import scala.concurrent.Future import scala.util.{ Failure, Success, Try } @@ -48,7 +47,7 @@ trait ParameterDirectives extends ParameterDirectivesInstances with ToNameRecept * * @group param */ - def parameterSeq: Directive1[immutable.Seq[(String, String)]] = _parameterSeq + def parameterSeq: Directive1[Seq[(String, String)]] = _parameterSeq } object ParameterDirectives extends ParameterDirectives { @@ -60,7 +59,7 @@ object ParameterDirectives extends ParameterDirectives { private val _parameterMultiMap: Directive1[Map[String, List[String]]] = extract(_.request.uri.query().toMultiMap) - private val _parameterSeq: Directive1[immutable.Seq[(String, String)]] = + private val _parameterSeq: Directive1[Seq[(String, String)]] = extract(_.request.uri.query().toSeq) trait ParamSpec { diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/RangeDirectives.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/RangeDirectives.scala index c82bfc32c9..b6dd534c7a 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/RangeDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/RangeDirectives.scala @@ -14,8 +14,6 @@ package org.apache.pekko.http.scaladsl.server package directives -import scala.collection.immutable - import org.apache.pekko import pekko.http.impl.util._ import pekko.http.scaladsl.model._ @@ -121,7 +119,7 @@ trait RangeDirectives { Multipart.ByteRanges(source) } - def rangeResponse(range: ByteRange, entity: UniversalEntity, length: Long, headers: immutable.Seq[HttpHeader]) = { + def rangeResponse(range: ByteRange, entity: UniversalEntity, length: Long, headers: Seq[HttpHeader]) = { val aiRange = indexRange(length)(range) HttpResponse(PartialContent, `Content-Range`(aiRange.contentRange(length)) +: headers, aiRange(entity)) } @@ -137,7 +135,7 @@ trait RangeDirectives { case _ => None } - def applyRanges(ranges: immutable.Seq[ByteRange]): Directive0 = + def applyRanges(ranges: Seq[ByteRange]): Directive0 = extractRequestContext.flatMap { ctx => mapRouteResultWithPF { case Complete(HttpResponse(OK, headers, entity, protocol)) => diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/RespondWithDirectives.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/RespondWithDirectives.scala index 7121bc4264..efcd3b540f 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/RespondWithDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/RespondWithDirectives.scala @@ -14,8 +14,6 @@ package org.apache.pekko.http.scaladsl.server package directives -import scala.collection.immutable - import org.apache.pekko import pekko.http.scaladsl.model._ @@ -32,7 +30,7 @@ trait RespondWithDirectives { * @group response */ def respondWithHeader(responseHeader: HttpHeader): Directive0 = - respondWithHeaders(immutable.Seq(responseHeader)) + respondWithHeaders(Seq(responseHeader)) /** * Adds the given response header to all HTTP responses of its inner Route, @@ -55,7 +53,7 @@ trait RespondWithDirectives { * * @group response */ - def respondWithHeaders(responseHeaders: immutable.Seq[HttpHeader]): Directive0 = + def respondWithHeaders(responseHeaders: Seq[HttpHeader]): Directive0 = mapResponseHeaders(responseHeaders.toList ++ _) /** @@ -73,7 +71,7 @@ trait RespondWithDirectives { * * @group response */ - def respondWithDefaultHeaders(responseHeaders: immutable.Seq[HttpHeader]): Directive0 = + def respondWithDefaultHeaders(responseHeaders: Seq[HttpHeader]): Directive0 = mapResponse(_.withDefaultHeaders(responseHeaders)) } diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/RouteDirectives.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/RouteDirectives.scala index 174adeac16..9aa651db1d 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/RouteDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/RouteDirectives.scala @@ -14,7 +14,6 @@ package org.apache.pekko.http.scaladsl.server package directives -import scala.collection.immutable import scala.concurrent.Future import org.apache.pekko @@ -74,7 +73,7 @@ trait RouteDirectives { * * @group route */ - def complete[T](status: StatusCode, headers: immutable.Seq[HttpHeader], v: => T)( + def complete[T](status: StatusCode, headers: Seq[HttpHeader], v: => T)( implicit m: ToEntityMarshaller[T]): StandardRoute = complete((status, headers, v)) diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/WebSocketDirectives.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/WebSocketDirectives.scala index 6ebb885063..b09b36b922 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/WebSocketDirectives.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/server/directives/WebSocketDirectives.scala @@ -14,8 +14,6 @@ package org.apache.pekko.http.scaladsl.server package directives -import scala.collection.immutable - import org.apache.pekko import pekko.http.scaladsl.model.AttributeKeys.webSocketUpgrade import pekko.http.scaladsl.model.ws.{ Message, WebSocketUpgrade } @@ -48,7 +46,7 @@ trait WebSocketDirectives { * * @group websocket */ - def extractOfferedWsProtocols: Directive1[immutable.Seq[String]] = + def extractOfferedWsProtocols: Directive1[Seq[String]] = extractWebSocketUpgrade.map(_.requestedProtocols) /** diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/unmarshalling/MultipartUnmarshallers.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/unmarshalling/MultipartUnmarshallers.scala index 6db02b8d92..34787e0d45 100644 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/unmarshalling/MultipartUnmarshallers.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/unmarshalling/MultipartUnmarshallers.scala @@ -81,7 +81,7 @@ trait MultipartUnmarshallers { createBodyPart: (BodyPartEntity, List[HttpHeader]) => BP, createStreamed: (MediaType.Multipart, Source[BP, Any]) => T, createStrictBodyPart: (HttpEntity.Strict, List[HttpHeader]) => BPS, - createStrict: (MediaType.Multipart, immutable.Seq[BPS]) => T)(implicit log: LoggingAdapter = NoLogging, + createStrict: (MediaType.Multipart, Seq[BPS]) => T)(implicit log: LoggingAdapter = NoLogging, parserSettings: ParserSettings = null): FromEntityUnmarshaller[T] = Unmarshaller.withMaterializer { implicit ec => implicit mat => entity => if (entity.contentType.mediaType.isMultipart && mediaRange.matches(entity.contentType.mediaType)) { diff --git a/http/src/main/scala/org/apache/pekko/http/scaladsl/unmarshalling/PredefinedFromStringUnmarshallers.scala b/http/src/main/scala/org/apache/pekko/http/scaladsl/unmarshalling/PredefinedFromStringUnmarshallers.scala index f0c3dc7818..c6dfa597bc 100755 --- a/http/src/main/scala/org/apache/pekko/http/scaladsl/unmarshalling/PredefinedFromStringUnmarshallers.scala +++ b/http/src/main/scala/org/apache/pekko/http/scaladsl/unmarshalling/PredefinedFromStringUnmarshallers.scala @@ -15,8 +15,6 @@ package org.apache.pekko.http.scaladsl.unmarshalling import java.util.UUID -import scala.collection.immutable - import org.apache.pekko import pekko.http.scaladsl.util.FastFuture import pekko.util.ByteString @@ -70,8 +68,8 @@ trait PredefinedFromStringUnmarshallers { } } - implicit def CsvSeq[T](implicit unmarshaller: Unmarshaller[String, T]): Unmarshaller[String, immutable.Seq[T]] = - Unmarshaller.strict[String, immutable.Seq[String]] { string => + implicit def CsvSeq[T](implicit unmarshaller: Unmarshaller[String, T]): Unmarshaller[String, Seq[T]] = + Unmarshaller.strict[String, Seq[String]] { string => string.split(",", -1).toList }.flatMap { implicit ec => implicit mat => strings => FastFuture.sequence(strings.map(unmarshaller(_))) 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 eb3d2d7211..d9c1c1e13b 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 @@ -13,7 +13,6 @@ package org.apache.pekko.http.impl.engine.http2 -import scala.collection.immutable import scala.concurrent.{ Future, Promise } import scala.concurrent.duration._ @@ -194,7 +193,7 @@ class Http2ClientServerSpec extends PekkoSpecWithMaterializer( def sendResponseWithEntityStream( status: StatusCode = StatusCodes.OK, - headers: immutable.Seq[HttpHeader] = Nil): TestPublisher.Probe[ByteString] = { + headers: Seq[HttpHeader] = Nil): TestPublisher.Probe[ByteString] = { val probe = TestPublisher.probe[ByteString]() sendResponse(HttpResponse(status, headers, HttpEntity(ContentTypes.`application/octet-stream`, Source.fromPublisher(probe)))) @@ -238,7 +237,7 @@ class Http2ClientServerSpec extends PekkoSpecWithMaterializer( requestId: String, method: HttpMethod = HttpMethods.POST, uri: Uri = Uri./, - headers: immutable.Seq[HttpHeader] = Nil): TestPublisher.Probe[ByteString] = { + headers: Seq[HttpHeader] = Nil): TestPublisher.Probe[ByteString] = { val probe = TestPublisher.probe[ByteString]() sendClientRequest( HttpRequest(method, uri, headers, 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 d4839f5f5e..96d8c7cf68 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 @@ -15,7 +15,6 @@ package org.apache.pekko.http.impl.engine.http2 import javax.net.ssl.SSLContext -import scala.collection.immutable import scala.concurrent.ExecutionContext import scala.concurrent.Future import scala.concurrent.duration._ @@ -1045,7 +1044,7 @@ class Http2ClientSpec extends PekkoSpecWithMaterializer(""" network.toNet.expectBytes(Http2Protocol.ClientConnectionPreface) network.expectSETTINGS() - network.sendFrame(SettingsFrame(immutable.Seq.empty ++ initialServerSettings)) + network.sendFrame(SettingsFrame(Seq.empty ++ initialServerSettings)) network.expectSettingsAck() def connectionShouldStillBeUsable(): Unit = { 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 9396fe16a1..7378681ded 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 @@ -15,7 +15,6 @@ package org.apache.pekko.http.impl.engine.http2 import java.net.InetSocketAddress -import scala.collection.immutable import scala.concurrent.{ Future, Promise } import scala.concurrent.duration._ @@ -344,7 +343,7 @@ abstract class Http2PersistentClientSpec(tls: Boolean) extends PekkoSpecWithMate def sendResponseWithEntityStream( status: StatusCode = StatusCodes.OK, - headers: immutable.Seq[HttpHeader] = Nil): TestPublisher.Probe[ByteString] = { + headers: Seq[HttpHeader] = Nil): TestPublisher.Probe[ByteString] = { val probe = TestPublisher.probe[ByteString]() sendResponse(HttpResponse(status, headers, HttpEntity(ContentTypes.`application/octet-stream`, Source.fromPublisher(probe)))) @@ -421,7 +420,7 @@ abstract class Http2PersistentClientSpec(tls: Boolean) extends PekkoSpecWithMate requestId: String, method: HttpMethod = HttpMethods.POST, uri: Uri = Uri./, - headers: immutable.Seq[HttpHeader] = Nil): TestPublisher.Probe[ByteString] = { + headers: Seq[HttpHeader] = Nil): TestPublisher.Probe[ByteString] = { val probe = TestPublisher.probe[ByteString]() sendRequest( HttpRequest(method, uri, headers, 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 55f6adc393..93798c28df 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 @@ -13,8 +13,6 @@ package org.apache.pekko.http.impl.engine.http2 -import scala.collection.immutable.Seq - import org.apache.pekko import pekko.http.impl.engine.http2.FrameEvent.{ ParsedHeadersFrame, Setting, SettingsFrame } import pekko.http.impl.engine.http2.Http2Protocol.SettingIdentifier 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 9ced005fb6..8bbab8a0d5 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 @@ -15,7 +15,6 @@ package org.apache.pekko.http.impl.engine.http2 import javax.net.ssl.SSLContext -import scala.collection.immutable import scala.concurrent.{ Await, Promise } import scala.concurrent.duration._ @@ -1271,11 +1270,11 @@ class Http2ServerSpec extends Http2SpecWithMaterializer(""" Source(List( HttpEntity.Chunk("foo"), HttpEntity.Chunk("bar"), - HttpEntity.LastChunk(trailer = immutable.Seq[HttpHeader](RawHeader("Status", "grpc-status 10"))))))) + HttpEntity.LastChunk(trailer = Seq[HttpHeader](RawHeader("Status", "grpc-status 10"))))))) user.emitResponse(TheStreamId, response) network.expectDecodedHEADERS(streamId = TheStreamId, endStream = false) network.expectDATA(TheStreamId, endStream = false, ByteString("foobar")) - network.expectDecodedHEADERS(streamId = TheStreamId).headers should be(immutable.Seq(RawHeader("status", + network.expectDecodedHEADERS(streamId = TheStreamId).headers should be(Seq(RawHeader("status", "grpc-status 10"))) }) "include the trailing headers even when the buffer is emptied before sending the last chunk".inAssertAllStagesStopped( @@ -1295,10 +1294,10 @@ class Http2ServerSpec extends Http2SpecWithMaterializer(""" network.expectDecodedHEADERS(streamId = TheStreamId, endStream = false) network.expectDATA(TheStreamId, endStream = false, ByteString("foobar")) - chunkQueue.offer(HttpEntity.LastChunk(trailer = immutable.Seq[HttpHeader](RawHeader("Status", + chunkQueue.offer(HttpEntity.LastChunk(trailer = Seq[HttpHeader](RawHeader("Status", "grpc-status 10")))) chunkQueue.complete() - network.expectDecodedHEADERS(streamId = TheStreamId).headers should be(immutable.Seq(RawHeader("status", + network.expectDecodedHEADERS(streamId = TheStreamId).headers should be(Seq(RawHeader("status", "grpc-status 10"))) }) "send the trailing headers immediately, even when the stream window is depleted".inAssertAllStagesStopped( @@ -1326,10 +1325,10 @@ class Http2ServerSpec extends Http2SpecWithMaterializer(""" network.expectDecodedHEADERS(streamId = TheStreamId, endStream = false) depleteWindow() - chunkQueue.offer(HttpEntity.LastChunk(trailer = immutable.Seq[HttpHeader](RawHeader("grpc-status", "10")))) + chunkQueue.offer(HttpEntity.LastChunk(trailer = Seq[HttpHeader](RawHeader("grpc-status", "10")))) chunkQueue.complete() network.expectDecodedHEADERS(streamId = TheStreamId, endStream = true).headers should be( - immutable.Seq(RawHeader("grpc-status", "10"))) + Seq(RawHeader("grpc-status", "10"))) }) "send the trailing headers even when last data chunk was delayed by window depletion".inAssertAllStagesStopped( new WaitingForResponseSetup { @@ -1358,7 +1357,7 @@ class Http2ServerSpec extends Http2SpecWithMaterializer(""" val lastData = ByteString("y" * 500) chunkQueue.offer(HttpEntity.Chunk(lastData)) // even out of connection window try to send one last chunk that will be buffered - chunkQueue.offer(HttpEntity.LastChunk(trailer = immutable.Seq[HttpHeader](RawHeader("grpc-status", "10")))) + chunkQueue.offer(HttpEntity.LastChunk(trailer = Seq[HttpHeader](RawHeader("grpc-status", "10")))) chunkQueue.complete() network.toNet.request(1) @@ -1373,7 +1372,7 @@ class Http2ServerSpec extends Http2SpecWithMaterializer(""" network.expectDATA(TheStreamId, endStream = false, lastData.drop(100)) network.expectDecodedHEADERS(streamId = TheStreamId, endStream = true).headers should be( - immutable.Seq(RawHeader("grpc-status", "10"))) + Seq(RawHeader("grpc-status", "10"))) }) "reject stream-level WINDOW_UPDATE that would overflow the flow-control window with FLOW_CONTROL_ERROR" diff --git a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2SpecWithMaterializer.scala b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2SpecWithMaterializer.scala index 52042218a0..3c7bb15762 100644 --- a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2SpecWithMaterializer.scala +++ b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2SpecWithMaterializer.scala @@ -13,7 +13,6 @@ package org.apache.pekko.http.impl.engine.http2 -import scala.collection.immutable import scala.concurrent.{ ExecutionContext, Future } import org.apache.pekko @@ -93,7 +92,7 @@ abstract class Http2SpecWithMaterializer(configOverrides: String) extends PekkoS network.sendBytes(Http2Protocol.ClientConnectionPreface) network.expectSETTINGS() - network.sendFrame(SettingsFrame(immutable.Seq.empty ++ initialClientSettings)) + network.sendFrame(SettingsFrame(Seq.empty ++ initialClientSettings)) network.expectSettingsAck() } diff --git a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/HttpMessageRenderingSpec.scala b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/HttpMessageRenderingSpec.scala index 6f9bd4e16f..87f09dac1a 100644 --- a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/HttpMessageRenderingSpec.scala +++ b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/HttpMessageRenderingSpec.scala @@ -16,7 +16,6 @@ package org.apache.pekko.http.impl.engine.http2 import java.time.format.DateTimeFormatter import scala.collection.immutable -import scala.collection.immutable.Seq import scala.collection.immutable.VectorBuilder import scala.util.Try @@ -169,12 +168,12 @@ class HttpMessageRenderingSpec extends AnyWordSpec with Matchers { } - private def renderClientHeaders(headers: immutable.Seq[HttpHeader], builder: VectorBuilder[(String, String)], + private def renderClientHeaders(headers: Seq[HttpHeader], builder: VectorBuilder[(String, String)], peerIdHeader: Option[(String, String)] = None): Unit = HttpMessageRendering.renderHeaders(headers, builder, peerIdHeader, NoLogging, isServer = false, shouldRenderAutoHeaders = true, dateHeaderRendering = DateHeaderRendering.Unavailable) - private def renderServerHeaders(headers: immutable.Seq[HttpHeader], builder: VectorBuilder[(String, String)], + private def renderServerHeaders(headers: Seq[HttpHeader], builder: VectorBuilder[(String, String)], peerIdHeader: Option[(String, String)] = None): Unit = HttpMessageRendering.renderHeaders(headers, builder, peerIdHeader, NoLogging, isServer = true, shouldRenderAutoHeaders = true, diff --git a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/framing/Http2FramingSpec.scala b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/framing/Http2FramingSpec.scala index 9c78fa66bb..f40e8327f5 100644 --- a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/framing/Http2FramingSpec.scala +++ b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/framing/Http2FramingSpec.scala @@ -14,7 +14,6 @@ package org.apache.pekko.http.impl.engine.http2 package framing -import scala.collection.immutable import scala.concurrent.duration._ import FrameEvent._ @@ -509,11 +508,11 @@ class Http2FramingSpec extends PekkoSpecWithMaterializer { result } - private def parseToEvents(bytes: Seq[ByteString]): immutable.Seq[FrameEvent] = + private def parseToEvents(bytes: Seq[ByteString]): Seq[FrameEvent] = Source(bytes.toVector).via(new Http2FrameParsing(shouldReadPreface = false, Logging(system, classOf[Http2FramingSpec]))).runWith(Sink.seq) .awaitResult(1.second.dilated) - private def renderToByteString(events: immutable.Seq[FrameEvent]): ByteString = + private def renderToByteString(events: Seq[FrameEvent]): ByteString = Source(events).map(FrameRenderer.render).runFold(ByteString.empty)(_ ++ _) .awaitResult(1.second.dilated) }