Packages

object ContentDecoder

Library of built-in content decoders.

This provides content decoder functions for the common scala types, and implicit decoder configured with a set of sensible default.

The implicitly provided decoders are chosen by the compiler and cannot be explicitly configured. In particular they are automatically configured with a MaxSize limit that specify the maximum amount of bytes they are authorized to read in memory.

It means that for example, this code:

val str: String = request.readAs[String]

will truncate the content body if it is bigger than the MaxSize property. The default for MaxSize is 1MB, and can be configured globally via the lol.http.ContentDecoder.maxSizeInMemory system property.

If you want to configure the content decoder to allow it to read more data despite the maximum set in MaxSize, you can just pass the content decoder yourself instead of relying on implicit resolution:

val str: String = request.readAs(text(maxSize = 10 * 1024 * 1024))
Source
Content.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ContentDecoder
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. val MaxSize: Int

    Default configuration for the maximum amount of bytes a decoder can read in memory.

    Default configuration for the maximum amount of bytes a decoder can read in memory. Default to 1MB, and can be configured globally via lol.http.ContentDecoder.maxSizeInMemory system property.

  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def binary(maxSize: Int = MaxSize): ContentDecoder[Array[Byte]]

    Create binary content decoders.

    Create binary content decoders. They read the byte stream in memory and return them as an Array[Byte].

    maxSize

    the maximum amount of bytes that can read in memory.

    returns

    a content decoder for Array[Byte].

  7. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )
  8. implicit val defaultBinary: ContentDecoder[Array[Byte]]

    Default binary content decoder configured with maxSize equals to MaxSize.

  9. implicit val defaultText: ContentDecoder[String]

    Default text content decoder configured with maxSize equals to MaxSize and defaultCodec to UTF-8.

  10. implicit val defaultUrlEncoded: ContentDecoder[Map[String, Seq[String]]]

    Default url-encoded-form-data decoder configured with maxSize equals to MaxSize.

  11. implicit val defaultUrlEncoded0: ContentDecoder[Map[String, String]]

    Default url-encoded-form-data decoder for Map[String,String].

  12. implicit val discard: ContentDecoder[Unit]

    A content decoder that discard everything from the stream and returns Unit.

  13. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  15. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  16. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  17. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  18. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  19. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  20. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  21. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  22. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  23. def text(maxSize: Int = MaxSize, defaultCodec: Codec = Codec.UTF8): ContentDecoder[String]

    Create text content decoders.

    Create text content decoders. They read the byte stream in memory and return them as a String. The decoder looks for the charset to use in the Content-Type HTTP header, or otherwise fallback to the provided default codec.

    maxSize

    the maximum amount of bytes that can read in memory.

    defaultCodec

    the default codec to use to decode the bytes as text if not specified in the Content-Type HTTP header.

    returns

    a content decoder for Array[Byte].

  24. def toString(): String
    Definition Classes
    AnyRef → Any
  25. def urlEncoded(maxSize: Int = MaxSize, codec: Codec = UsAscii): ContentDecoder[Map[String, Seq[String]]]

    Create content decoder for url-encoded-form-data.

    Create content decoder for url-encoded-form-data. The content is converted to a Map[String,Seq[String]]. See https://www.w3.org/TR/html5/forms.html#url-encoded-form-data.

    maxSize

    the maximum amount of bytes that can read in memory.

    codec

    the codec to use to read the content (should be us-ascii as defined in the specification).

    returns

    a content decoder for Map[String,Seq[String]].

  26. def urlEncoded0(maxSize: Int = MaxSize, codec: Codec = UsAscii): ContentDecoder[Map[String, String]]

    Same as urlEncoded but keeps only one value per key, therefore producing a Map[String,String] value.

  27. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped