Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/src/main/paradox/release-notes/releases-2.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@

Pekko HTTP 2.1.0 has not been released yet. These notes list the changes merged so far.

### Removed APIs

These removals are source and binary incompatible with Pekko HTTP 2.0. Recompile applications and
libraries that used the removed members against the replacement APIs before upgrading.

* For HTTP 413 and 422, use Scala `ContentTooLarge` and `UnprocessableContent` or Java
`CONTENT_TOO_LARGE` and `UNPROCESSABLE_CONTENT`. The wire status codes are unchanged.
* Replace the four-argument Scala `HttpMethod.custom` and Java `HttpMethods.custom` factories with
the five-argument overload. Choose `contentLengthAllowed` for the method explicitly; a fixed Boolean
is not equivalent to the old status-dependent rule.
* In the Java routing DSL, use the `java.time.Duration` overloads of `withRequestTimeout`,
`extractStrictEntity` and `toStrictEntity` for finite durations. To disable the timeout, use
`withoutRequestTimeout`. This does not also install a timeout response handler.
* The legacy Scala coding implementation types (`Gzip`, `Deflate`, `NoCoding`, `StreamDecoder`
and `Compressor`) are now package-internal. Use `Coders.Gzip`, `Coders.Deflate` and
`Coders.NoCoding` for built-in codecs, or `Coders.fromFlows` for a custom codec. The Java
`Coder` enum and its built-in variants are unchanged.

### Behavior Changes

* The `Link` header parser now accepts unquoted `anchor` values that are valid HTTP tokens and URI references,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
package docs.http.scaladsl.server.directives

import org.apache.pekko
import pekko.http.scaladsl.coding.{ Coder, Coders, Gzip }
import pekko.http.scaladsl.coding.{ Coder, Coders }
import pekko.http.scaladsl.model.{ HttpEntity, HttpResponse }
import pekko.http.scaladsl.model.headers.{ `Accept-Encoding`, `Content-Encoding`, HttpEncoding, HttpEncodings }
import pekko.http.scaladsl.model.headers.HttpEncodings._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,6 @@ private HttpMethods() {}
public static final HttpMethod QUERY = org.apache.pekko.http.scaladsl.model.HttpMethods.QUERY();
public static final HttpMethod TRACE = org.apache.pekko.http.scaladsl.model.HttpMethods.TRACE();

/**
* Create a custom method type.
*
* @deprecated The created method will compute the presence of Content-Length headers based on
* deprecated logic, use {@link #custom(String, boolean, boolean,
* org.apache.pekko.http.javadsl.model.RequestEntityAcceptance, boolean)} instead. Deprecated
* since 1.4.0.
*/
@Deprecated(since = "1.4.0")
public static HttpMethod custom(
String value,
boolean safe,
boolean idempotent,
org.apache.pekko.http.javadsl.model.RequestEntityAcceptance requestEntityAcceptance) {
// This cast is safe as implementation of RequestEntityAcceptance only exists in Scala
org.apache.pekko.http.scaladsl.model.RequestEntityAcceptance scalaRequestEntityAcceptance =
(org.apache.pekko.http.scaladsl.model.RequestEntityAcceptance) requestEntityAcceptance;
return org.apache.pekko.http.scaladsl.model.HttpMethod.custom(
value, safe, idempotent, scalaRequestEntityAcceptance);
}

/**
* Create a custom method type.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,6 @@ private StatusCodes() {}
public static final StatusCode CONTENT_TOO_LARGE =
org.apache.pekko.http.scaladsl.model.StatusCodes.ContentTooLarge();

/**
* @deprecated deprecated in favor of CONTENT_TOO_LARGE since 1.1.0
*/
@Deprecated(since = "1.1.0")
public static final StatusCode PAYLOAD_TOO_LARGE =
org.apache.pekko.http.scaladsl.model.StatusCodes.PayloadTooLarge();

public static final StatusCode URI_TOO_LONG =
org.apache.pekko.http.scaladsl.model.StatusCodes.UriTooLong();

Expand All @@ -126,13 +119,6 @@ private StatusCodes() {}
public static final StatusCode UNPROCESSABLE_CONTENT =
org.apache.pekko.http.scaladsl.model.StatusCodes.UnprocessableContent();

/**
* @deprecated deprecated in favor of UNPROCESSABLE_CONTENT since 1.1.0
*/
@Deprecated(since = "1.1.0")
public static final StatusCode UNPROCESSABLE_ENTITY =
org.apache.pekko.http.scaladsl.model.StatusCodes.UnprocessableEntity();

public static final StatusCode LOCKED = org.apache.pekko.http.scaladsl.model.StatusCodes.Locked();
public static final StatusCode FAILED_DEPENDENCY =
org.apache.pekko.http.scaladsl.model.StatusCodes.FailedDependency();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# Intentional removals of public APIs deprecated before 2.0; keep every other overload checked.
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.model.HttpMethods.custom(java.lang.String,Boolean,Boolean,org.apache.pekko.http.javadsl.model.RequestEntityAcceptance)org.apache.pekko.http.javadsl.model.HttpMethod")
ProblemFilters.exclude[MissingFieldProblem]("org.apache.pekko.http.javadsl.model.StatusCodes.PAYLOAD_TOO_LARGE")
ProblemFilters.exclude[MissingFieldProblem]("org.apache.pekko.http.javadsl.model.StatusCodes.UNPROCESSABLE_ENTITY")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.model.HttpMethod.custom(java.lang.String,Boolean,Boolean,org.apache.pekko.http.scaladsl.model.RequestEntityAcceptance)org.apache.pekko.http.scaladsl.model.HttpMethod")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.model.StatusCodes.PayloadTooLarge()org.apache.pekko.http.scaladsl.model.StatusCodes#ClientError")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.scaladsl.model.StatusCodes.UnprocessableEntity()org.apache.pekko.http.scaladsl.model.StatusCodes#ClientError")
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,6 @@ final case class HttpMethod private[http] (

object HttpMethod {

// the allowsEntity condition was used to determine what responses provided the Content-Length header, before the fix
private def oldContentLengthCondition(status: StatusCode) = status.allowsEntity

/**
* Create a custom method type.
* @deprecated The created method will compute the presence of Content-Length headers based on deprecated logic.
*/
@deprecated("Use the overload with contentLengthAllowed parameter", since = "1.4.0")
def custom(name: String, safe: Boolean, idempotent: Boolean, requestEntityAcceptance: RequestEntityAcceptance)
: HttpMethod = {
requireToken(name)
require(!safe || idempotent, "An HTTP method cannot be safe without being idempotent")
apply(name, safe, idempotent, requestEntityAcceptance, oldContentLengthCondition)
}

/**
* Create a custom method type.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,6 @@ object StatusCodes extends ObjectRegistry[Int, StatusCode] {
val LengthRequired = reg(c(411)("Length Required", "The request did not specify the length of its content, which is required by the requested resource."))
val PreconditionFailed = reg(c(412)("Precondition Failed", "The server does not meet one of the preconditions that the requester put on the request."))
val ContentTooLarge = reg(c(413)("Content Too Large", "The request content is larger than the server is willing or able to process."))
@deprecated("deprecated in favor of ContentTooLarge", "1.1.0")
val PayloadTooLarge = ContentTooLarge
val UriTooLong = reg(c(414)("URI Too Long", "The URI provided was too long for the server to process."))
val UnsupportedMediaType = reg(c(415)("Unsupported Media Type", "The request entity has a media type which the server or resource does not support."))
val RangeNotSatisfiable = reg(c(416)("Range Not Satisfiable", "The client has asked for a portion of the file, but the server cannot supply that portion."))
Expand All @@ -188,8 +186,6 @@ object StatusCodes extends ObjectRegistry[Int, StatusCode] {
val EnhanceYourCalm = reg(c(420)("Enhance Your Calm", "You are being rate-limited.")) // Twitter only
val MisdirectedRequest = reg(c(421)("Misdirected Request", "The request was directed at a server that is not able to produce a response.")) // RFC 9110 section 15.5.20
val UnprocessableContent = reg(c(422)("Unprocessable Content", "The request was well-formed but was unable to be followed due to semantic errors."))
@deprecated("deprecated in favor of UnprocessableContent", "1.1.0")
val UnprocessableEntity = UnprocessableContent
val Locked = reg(c(423)("Locked", "The resource that is being accessed is locked."))
val FailedDependency = reg(c(424)("Failed Dependency", "The request failed due to failure of a previous request."))
val TooEarly = reg(c(425)("Too Early", "The server is unwilling to risk processing a request that might be replayed.")) // RFC 8470
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class HostConnectionPoolSpec extends PekkoSpecWithMaterializer(
reqInProbe.expectUtf8EncodedString("test")

// the server rejects the request before the request entity has been sent completely
conn1.pushResponse(HttpResponse(StatusCodes.PayloadTooLarge, entity = "too large"))
conn1.pushResponse(HttpResponse(StatusCodes.ContentTooLarge, entity = "too large"))
expectResponseEntityAsString() shouldEqual "too large"

// the rest of the request entity is not sent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class SlotStateSpec extends PekkoSpec {
}

"close the connection right away after an early error response" in {
earlyResponseCompleted(new MockSlotContext(system.log), HttpResponse(StatusCodes.PayloadTooLarge)) should
earlyResponseCompleted(new MockSlotContext(system.log), HttpResponse(StatusCodes.ContentTooLarge)) should
be(ToBeClosed)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.apache.pekko.http.scaladsl.coding

import scala.annotation.nowarn
import scala.concurrent.duration._

import org.apache.pekko
Expand Down Expand Up @@ -128,7 +127,6 @@ class CodersSpec extends AnyWordSpec with CodecSpecSupport {
}

"preserve custom stream decoders' explicit choice of a compatible codec" in {
@nowarn("msg=deprecated")
val custom = new StreamDecoder {
val encoding = HttpEncoding.custom("x-application-gzip")
protected def newDecompressorStage(maxBytesPerChunk: Int) = () => new GzipDecompressor(maxBytesPerChunk)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

package org.apache.pekko.http.scaladsl.coding

import scala.annotation.nowarn
import scala.concurrent.duration._

import org.apache.pekko
Expand Down Expand Up @@ -49,7 +48,6 @@ class DecoderSpec extends AnyWordSpec with CodecSpecSupport {
def dummyDecompress(s: String): String = dummyDecompress(ByteString(s, "UTF8")).decodeString("UTF8")
def dummyDecompress(bytes: ByteString): ByteString = DummyDecoder.decode(bytes).awaitResult(3.seconds.dilated)

@nowarn("msg=is internal API")
case object DummyDecoder extends StreamDecoder {
val encoding = HttpEncodings.compress

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import java.util.concurrent.{ CountDownLatch, TimeUnit }
import java.util.concurrent.atomic.AtomicInteger
import java.util.zip._

import scala.annotation.nowarn
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._

Expand Down Expand Up @@ -119,15 +118,13 @@ class DeflateSpec extends CoderSpec {
private def decodeWith(inflater: TrackingInflater, bytes: ByteString): ByteString =
decoderWith(inflater).decode(bytes)(SystemMaterializer(system).materializer).awaitResult(3.seconds.dilated)

@nowarn("msg=deprecated")
private def encoderWith(tracking: TrackingDeflater): Deflate =
new Deflate(Encoder.DefaultFilter) {
override private[http] def newCompressor: DeflateCompressor = new DeflateCompressor() {
override protected lazy val deflater: java.util.zip.Deflater = tracking
}
}

@nowarn("msg=deprecated")
private def decoderWith(inflater: TrackingInflater): StreamDecoder =
new StreamDecoder {
override val encoding = HttpEncodings.deflate
Expand Down Expand Up @@ -168,7 +165,6 @@ class DeflateSpec extends CoderSpec {
}

private def encodeMessage(request: HttpRequest, compressionLevel: Int, noWrap: Boolean): HttpRequest = {
@nowarn("msg=deprecated .* is internal API")
val deflaterWithoutWrapping = new Deflate(Encoder.DefaultFilter) {
override def newCompressor = new DeflateCompressor(compressionLevel) {
override lazy val deflater = new Deflater(compressionLevel, noWrap)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

package org.apache.pekko.http.scaladsl.coding

import scala.annotation.nowarn
import scala.concurrent.duration._

import org.apache.pekko
Expand Down Expand Up @@ -51,7 +50,6 @@ class EncoderSpec extends AnyWordSpec with CodecSpecSupport {
def newCompressor = DummyCompressor
}

@nowarn("msg=is internal API")
case object DummyCompressor extends Compressor {
def compress(input: ByteString) = input ++ ByteString("compressed")
def flush() = ByteString.empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import java.util.concurrent.{ CountDownLatch, TimeUnit }
import java.util.concurrent.atomic.AtomicInteger
import java.util.zip.{ GZIPInputStream, GZIPOutputStream, Inflater, ZipException }

import scala.annotation.nowarn
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._

Expand Down Expand Up @@ -145,7 +144,6 @@ class GzipSpec extends CoderSpec {
private def decodeWith(tracking: TrackingInflater, bytes: ByteString): ByteString =
decoderWith(tracking).decode(bytes)(SystemMaterializer(system).materializer).awaitResult(3.seconds.dilated)

@nowarn("msg=deprecated")
private def decoderWith(tracking: TrackingInflater): Gzip =
new Gzip(Encoder.DefaultFilter) {
override def newDecompressorStage(maxBytesPerChunk: Int) =
Expand All @@ -155,7 +153,6 @@ class GzipSpec extends CoderSpec {
}
}

@nowarn("msg=deprecated")
private def encoderWith(tracking: TrackingDeflater): Gzip =
new Gzip(Encoder.DefaultFilter) {
override private[http] def newCompressor: GzipCompressor = new GzipCompressor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package org.apache.pekko.http.scaladsl.coding

import java.io.{ InputStream, OutputStream }

import scala.annotation.nowarn
import scala.concurrent.duration._

import com.github.luben.zstd.{ ZstdInputStream, ZstdOutputStream }
Expand Down Expand Up @@ -133,7 +132,6 @@ class ZstdSpec extends CoderSpec {
windowBase + (windowBase / 8) * (windowDescriptor & 0x7)
}

@nowarn("msg=deprecated")
private def encoderWith(compressor: Compressor): Encoder =
new Encoder {
override def encoding: HttpEncoding = HttpEncodings.zstd
Expand Down
19 changes: 8 additions & 11 deletions http/src/main/java/org/apache/pekko/http/javadsl/coding/Coder.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,21 @@
import org.apache.pekko.http.javadsl.model.HttpRequest;
import org.apache.pekko.http.javadsl.model.HttpResponse;
import org.apache.pekko.http.scaladsl.coding.Coders$;
import org.apache.pekko.http.scaladsl.coding.Deflate$;
import org.apache.pekko.http.scaladsl.coding.Gzip$;
import org.apache.pekko.http.scaladsl.coding.NoCoding$;
import org.apache.pekko.http.scaladsl.coding.Encoder$;
import org.apache.pekko.http.scaladsl.coding.Zstd$;
import org.apache.pekko.stream.Materializer;
import org.apache.pekko.util.ByteString;
import scala.jdk.javaapi.FutureConverters;

/** A coder is an implementation of the predefined encoders/decoders defined for HTTP. */
@SuppressWarnings("deprecation")
public enum Coder {
NoCoding(NoCoding$.MODULE$),
Deflate(Deflate$.MODULE$),
Gzip(Gzip$.MODULE$),
DeflateLevel1(Deflate$.MODULE$.withLevel(1)),
DeflateLevel9(Deflate$.MODULE$.withLevel(9)),
GzipLevel1(Gzip$.MODULE$.withLevel(1)),
GzipLevel9(Gzip$.MODULE$.withLevel(9)),
NoCoding(Coders$.MODULE$.NoCoding()),
Deflate(Coders$.MODULE$.Deflate()),
Gzip(Coders$.MODULE$.Gzip()),
DeflateLevel1(Coders$.MODULE$.Deflate(Encoder$.MODULE$.DefaultFilter(), 1)),
DeflateLevel9(Coders$.MODULE$.Deflate(Encoder$.MODULE$.DefaultFilter(), 9)),
GzipLevel1(Coders$.MODULE$.Gzip(Encoder$.MODULE$.DefaultFilter(), 1)),
GzipLevel9(Coders$.MODULE$.Gzip(Encoder$.MODULE$.DefaultFilter(), 9)),
/**
* The 'zstd' encoding, which needs the optional {@code com.github.luben:zstd-jni} dependency on
* the classpath.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# Intentional removals of public APIs deprecated before 2.0; keep every other overload checked.
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.server.directives.BasicDirectives.extractStrictEntity(scala.concurrent.duration.FiniteDuration,java.util.function.Function)org.apache.pekko.http.javadsl.server.Route")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.server.directives.BasicDirectives.extractStrictEntity(scala.concurrent.duration.FiniteDuration,Long,java.util.function.Function)org.apache.pekko.http.javadsl.server.Route")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.server.directives.BasicDirectives.toStrictEntity(scala.concurrent.duration.FiniteDuration,java.util.function.Supplier)org.apache.pekko.http.javadsl.server.Route")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.server.directives.BasicDirectives.toStrictEntity(scala.concurrent.duration.FiniteDuration,Long,java.util.function.Supplier)org.apache.pekko.http.javadsl.server.Route")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.server.directives.TimeoutDirectives.withRequestTimeout(scala.concurrent.duration.Duration,java.util.function.Supplier)org.apache.pekko.http.javadsl.server.directives.RouteAdapter")
ProblemFilters.exclude[DirectMissingMethodProblem]("org.apache.pekko.http.javadsl.server.directives.TimeoutDirectives.withRequestTimeout(scala.concurrent.duration.Duration,java.util.function.Function,java.util.function.Supplier)org.apache.pekko.http.javadsl.server.directives.RouteAdapter")
Loading
Loading