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
- Alphabetic
- By Inheritance
- ContentDecoder
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
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 vialol.http.ContentDecoder.maxSizeInMemory
system property. -
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
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]
.
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
implicit
val
defaultBinary: ContentDecoder[Array[Byte]]
Default binary content decoder configured with
maxSize
equals to MaxSize. -
implicit
val
defaultText: ContentDecoder[String]
Default text content decoder configured with
maxSize
equals to MaxSize anddefaultCodec
to UTF-8. -
implicit
val
defaultUrlEncoded: ContentDecoder[Map[String, Seq[String]]]
Default
url-encoded-form-data
decoder configured withmaxSize
equals to MaxSize. -
implicit
val
defaultUrlEncoded0: ContentDecoder[Map[String, String]]
Default
url-encoded-form-data
decoder forMap[String,String]
. -
implicit
val
discard: ContentDecoder[Unit]
A content decoder that discard everything from the stream and returns
Unit
. -
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
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 theContent-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]
.
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
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 aMap[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]]
.
-
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. -
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )