EntityDecoder

org.http4s.EntityDecoder
See theEntityDecoder companion trait
object EntityDecoder

EntityDecoder is used to attempt to decode an Entity This companion object provides a way to create new EntityDecoders along with some commonly used instances which can be resolved implicitly.

Attributes

Companion
trait
Source
EntityDecoder.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def apply[F[_], T](implicit ev: EntityDecoder[F, T]): EntityDecoder[F, T]

summon an implicit EntityDecoder

summon an implicit EntityDecoder

Attributes

Source
EntityDecoder.scala

Attributes

Source
EntityDecoder.scala

Helper method which simply gathers the body into a single Chunk

Helper method which simply gathers the body into a single Chunk

Attributes

Source
EntityDecoder.scala

Create a new EntityDecoder

Create a new EntityDecoder

The new EntityDecoder will attempt to decode messages of type T only if the Message satisfies the provided MediaRange.

Exceptions thrown by f are not caught. Care should be taken that recoverable errors are returned as a DecodeResult#failure, or that system errors are raised in F.

Attributes

Source
EntityDecoder.scala
def decodeText[F[_]](m: Media[F])(implicit F: Concurrent[F], defaultCharset: Charset): F[String]

Decodes a message to a String

Decodes a message to a String

Attributes

Source
EntityDecoder.scala
def error[F[_], T](t: Throwable)(implicit F: Concurrent[F]): EntityDecoder[F, T]

Provides a mechanism to fail decoding

Provides a mechanism to fail decoding

Attributes

Source
EntityDecoder.scala

Multipart decoder that streams all parts past a threshold (anything above maxSizeBeforeWrite) into a temporary file.

Multipart decoder that streams all parts past a threshold (anything above maxSizeBeforeWrite) into a temporary file. The decoder is only valid inside the Resource scope; once the Resource is released, all the created files are deleted.

Note that no files are deleted until the Resource is released. Thus, sharing and reusing the resulting EntityDecoder is not recommended, and can lead to disk space leaks.

The intended way to use this is as follows:

mixedMultipartResource[F]()
 .flatTap(request.decodeWith(_, strict = true))
 .use { multipart =>
   // Use the decoded entity
 }

Value parameters

chunkSize

the size of chunks created when reading data from temporary files.

failOnLimit

Fail if maxParts is exceeded _during_ multipart parsing.

headerLimit

the max size for the headers, in bytes. This is required as headers are strictly evaluated and parsed.

maxParts

the maximum number of parts this decoder accepts. NOTE: this also may mean that a body that doesn't conform perfectly to the spec (i.e isn't terminated properly) but has a lot of parts might be parsed correctly, despite the total body being malformed due to not conforming to the multipart spec. You can control this by failOnLimit, by setting it to true if you want to raise an error if sending too many parts to a particular endpoint

maxSizeBeforeWrite

the maximum size of a particular part before writing to a file is triggered

Attributes

Returns

A supervised multipart decoder.

Source
EntityDecoder.scala

Attributes

Source
EntityDecoder.scala

Deprecated methods

Multipart decoder that streams all parts past a threshold (anything above maxSizeBeforeWrite) into a temporary file.

Multipart decoder that streams all parts past a threshold (anything above maxSizeBeforeWrite) into a temporary file.

Note: (BIG NOTE) Using this decoder for multipart decoding is good for the sake of not holding all information in memory, as it will never have more than maxSizeBeforeWrite in memory before writing to a temporary file. On top of this, you can gate the # of parts to further stop the quantity of parts you can have. That said, because after a threshold it writes into a temporary file, given bincompat reasons on 0.18.x, there is no way to make a distinction about which Part[F] is a stream reference to a file or not. Thus, consumers using this decoder should drain all Part[F] bodies if they were decoded correctly. That said, this decoder gives you more control about how many part bodies it parses in the first place, thus you can have more fine-grained control about how many parts you accept.

Value parameters

failOnLimit

Fail if maxParts is exceeded _during_ multipart parsing.

headerLimit

the max size for the headers, in bytes. This is required as headers are strictly evaluated and parsed.

maxParts

the maximum number of parts this decoder accepts. NOTE: this also may mean that a body that doesn't conform perfectly to the spec (i.e isn't terminated properly) but has a lot of parts might be parsed correctly, despite the total body being malformed due to not conforming to the multipart spec. You can control this by failOnLimit, by setting it to true if you want to raise an error if sending too many parts to a particular endpoint

maxSizeBeforeWrite

the maximum size of a particular part before writing to a file is triggered

Attributes

Returns

A multipart/form-data encoded vector of parts with some part bodies held in temporary files.

Deprecated
true
Source
EntityDecoder.scala

Implicits

Implicits

implicit def binary[F[_] : Concurrent]: EntityDecoder[F, Chunk[Byte]]

Attributes

Source
EntityDecoder.scala

Attributes

Source
EntityDecoder.scala

Attributes

Source
EntityDecoder.scala

Attributes

Source
EntityDecoder.scala
implicit def multipart[F[_] : Concurrent]: EntityDecoder[F, Multipart[F]]

Attributes

Source
EntityDecoder.scala
implicit def semigroupKForEntityDecoder[F[_] : Functor]: SemigroupK[[_] =>> EntityDecoder[F, _$5]]

Attributes

Source
EntityDecoder.scala
implicit def text[F[_]](implicit F: Concurrent[F], defaultCharset: Charset): EntityDecoder[F, String]

Attributes

Source
EntityDecoder.scala
implicit def void[F[_] : Concurrent]: EntityDecoder[F, Unit]

An entity decoder that ignores the content and returns unit.

An entity decoder that ignores the content and returns unit.

Attributes

Source
EntityDecoder.scala

Deprecated implicits

Attributes

Deprecated
true
Source
EntityDecoder.scala