Enum Class Coder

java.lang.Object
java.lang.Enum<Coder>
org.apache.pekko.http.javadsl.coding.Coder
All Implemented Interfaces:
Serializable, Comparable<Coder>, Constable

public enum Coder extends Enum<Coder>
A coder is an implementation of the predefined encoders/decoders defined for HTTP.
  • Enum Constant Details

    • NoCoding

      public static final Coder NoCoding
    • Deflate

      public static final Coder Deflate
    • Gzip

      public static final Coder Gzip
    • DeflateLevel1

      public static final Coder DeflateLevel1
    • DeflateLevel9

      public static final Coder DeflateLevel9
    • GzipLevel1

      public static final Coder GzipLevel1
    • GzipLevel9

      public static final Coder GzipLevel9
    • Zstd

      public static final Coder Zstd
      The 'zstd' encoding, which needs the optional com.github.luben:zstd-jni dependency on the classpath.
      Since:
      2.0.0
  • Method Details

    • values

      public static Coder[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static Coder valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • encodeMessage

      public HttpResponse encodeMessage(HttpResponse message)
    • encodeMessage

      public HttpRequest encodeMessage(HttpRequest message)
    • decodeMessage

      public HttpResponse decodeMessage(HttpResponse message)
    • decodeMessage

      public HttpRequest decodeMessage(HttpRequest message)
    • decode

      public CompletionStage<org.apache.pekko.util.ByteString> decode(org.apache.pekko.util.ByteString input, org.apache.pekko.stream.Materializer mat)
    • _underlyingScalaCoder

      public Coder _underlyingScalaCoder()
    • decodeResponse

      public static HttpResponse decodeResponse(HttpResponse response, Coder... coders)
      Decodes the response with the one of coders whose encoding matches the response's Content-Encoding header, without having to check its encoding first. If no coders are given, Gzip, Deflate and NoCoding are used; Zstd has to be given explicitly.

      The response is returned unchanged if it has no Content-Encoding header, if none of coders matches its encoding, or if the header lists more than one encoding. In the last two cases the Content-Encoding header is kept, so response.encoding() shows that the entity is still encoded.

      Since:
      2.0.0
    • decodeRequest

      public static HttpRequest decodeRequest(HttpRequest request, Coder... coders)
      Decodes the request with the one of coders whose encoding matches the request's Content-Encoding header, see decodeResponse(HttpResponse, Coder...).
      Since:
      2.0.0