DefaultPlayBodyParsers

play.api.mvc.DefaultPlayBodyParsers
class DefaultPlayBodyParsers(val config: ParserConfiguration, val errorHandler: HttpErrorHandler, val materializer: Materializer, val temporaryFileCreator: TemporaryFileCreator) extends PlayBodyParsers

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Inherited methods

If empty file uploads are allowed (no matter if filename or file is empty)

If empty file uploads are allowed (no matter if filename or file is empty)

You can configure it in application.conf:

play.http.parser.allowEmptyFiles = true

Attributes

Inherited from:
PlayBodyParsers

Default max length allowed for disk based body.

Default max length allowed for disk based body.

You can configure it in application.conf:

play.http.parser.maxDiskBuffer = 512k

Attributes

Inherited from:
PlayBodyParsers

Default max length allowed for text based body.

Default max length allowed for text based body.

You can configure it in application.conf:

play.http.parser.maxMemoryBuffer = 100k

Attributes

Inherited from:
PlayBodyParsers

Guess the body content by checking the Content-Type header.

Guess the body content by checking the Content-Type header.

Attributes

Inherited from:
PlayBodyParsers

Guess the body content by checking the Content-Type header.

Guess the body content by checking the Content-Type header.

Attributes

Inherited from:
PlayBodyParsers

Buffer the body as a simple org.apache.pekko.util.ByteString.

Buffer the body as a simple org.apache.pekko.util.ByteString.

Will buffer up to the configured max memory buffer amount, after which point, it will return an EntityTooLarge HTTP response.

Attributes

Inherited from:
PlayBodyParsers
def byteString(maxLength: Long): BodyParser[ByteString]

Buffer the body as a simple org.apache.pekko.util.ByteString.

Buffer the body as a simple org.apache.pekko.util.ByteString.

Value parameters

maxLength

Max length (in bytes) allowed or returns EntityTooLarge HTTP response.

Attributes

Inherited from:
PlayBodyParsers
def default(maxLength: Option[Long]): BodyParser[AnyContent]

If the request has a body, parse the body content by checking the Content-Type header.

If the request has a body, parse the body content by checking the Content-Type header.

Attributes

Inherited from:
PlayBodyParsers

If the request has a body, parse the body content by checking the Content-Type header.

If the request has a body, parse the body content by checking the Content-Type header.

Attributes

Inherited from:
PlayBodyParsers

Attributes

Inherited from:
PlayBodyParsers

Don't parse the body content.

Don't parse the body content.

Attributes

Inherited from:
BodyParserUtils
def error[A](result: Future[Result]): BodyParser[A]

A body parser that always returns an error.

A body parser that always returns an error.

Attributes

Inherited from:
BodyParserUtils
def file(to: File): BodyParser[File]

Store the body content into a file.

Store the body content into a file.

Value parameters

to

The file used to store the content.

Attributes

Inherited from:
PlayBodyParsers
def file(to: File, maxLength: Long): BodyParser[File]

Store the body content into a file.

Store the body content into a file.

Value parameters

maxLength

Max length (in bytes) allowed or returns EntityTooLarge HTTP response.

to

The file used to store the content.

Attributes

Inherited from:
PlayBodyParsers
def flatten[A](underlying: Future[BodyParser[A]])(implicit ec: ExecutionContext, mat: Materializer): BodyParser[A]

A body parser that flattens a future BodyParser.

A body parser that flattens a future BodyParser.

Attributes

Inherited from:
BodyParserUtils
def form[A](form: Form[A], maxLength: Option[Long], onErrors: (Form[A]) => Result): BodyParser[A]

Parse the body and binds it to a given form model.

Parse the body and binds it to a given form model.

 case class User(name: String)

 val userForm: Form[User] = Form(mapping("name" -> nonEmptyText)(User.apply)(User.unapply))

 Action(parse.form(userForm)) { request =>
   Ok(s"Hello, ${request.body.name}!")
 }

Value parameters

form

Form model

maxLength

Max length (in bytes) allowed or returns EntityTooLarge HTTP response. If None, the default play.http.parser.maxMemoryBuffer configuration value is used.

onErrors

The result to reply in case of errors during the form binding process

Attributes

Inherited from:
PlayBodyParsers
def formBinding(maxChars: Long, maxDepth: Int): FormBinding

Attributes

Inherited from:
PlayBodyParsers

Parse the body as form url encoded if the Content-Type is application/x-www-form-urlencoded.

Parse the body as form url encoded if the Content-Type is application/x-www-form-urlencoded.

Attributes

Inherited from:
PlayBodyParsers

Parse the body as form url encoded if the Content-Type is application/x-www-form-urlencoded.

Parse the body as form url encoded if the Content-Type is application/x-www-form-urlencoded.

Value parameters

maxLength

Max length (in bytes) allowed or returns EntityTooLarge HTTP response.

Attributes

Inherited from:
PlayBodyParsers
def ignore[A](body: A): BodyParser[A]

Attributes

Inherited from:
BodyParserUtils
def json[A](implicit reader: Reads[A]): BodyParser[A]

Parse the body as Json if the Content-Type is text/json or application/json, validating the result with the Json reader.

Parse the body as Json if the Content-Type is text/json or application/json, validating the result with the Json reader.

Type parameters

A

the type to read and validate from the body.

Value parameters

reader

a Json reader for type A.

Attributes

Inherited from:
PlayBodyParsers

Parse the body as Json if the Content-Type is text/json or application/json.

Parse the body as Json if the Content-Type is text/json or application/json.

Attributes

Inherited from:
PlayBodyParsers
def json(maxLength: Long): BodyParser[JsValue]

Parse the body as Json if the Content-Type is text/json or application/json.

Parse the body as Json if the Content-Type is text/json or application/json.

Value parameters

maxLength

Max length (in bytes) allowed or returns EntityTooLarge HTTP response.

Attributes

Inherited from:
PlayBodyParsers
def maxLength[A](maxLength: Long, parser: BodyParser[A])(implicit mat: Materializer): BodyParser[Either[MaxSizeExceeded, A]]

Wrap an existing BodyParser with a maxLength constraints.

Wrap an existing BodyParser with a maxLength constraints.

Value parameters

maxLength

The max length allowed

parser

The BodyParser to wrap

Attributes

Inherited from:
BodyParserUtils
def multipartFormData[A](filePartHandler: () => A, maxLength: Long, allowEmptyFiles: Boolean): BodyParser[MultipartFormData[A]]

Parse the content as multipart/form-data

Parse the content as multipart/form-data

Value parameters

allowEmptyFiles

If empty file uploads are allowed (no matter if filename or file is empty)

filePartHandler

Handles file parts.

maxLength

Max length (in bytes) allowed or returns EntityTooLarge HTTP response.

Attributes

See also
Inherited from:
PlayBodyParsers

Parse the content as multipart/form-data

Parse the content as multipart/form-data

Value parameters

allowEmptyFiles

If empty file uploads are allowed (no matter if filename or file is empty)

maxLength

Max length (in bytes) allowed or returns EntityTooLarge HTTP response.

Attributes

Inherited from:
PlayBodyParsers

Parse the content as multipart/form-data

Parse the content as multipart/form-data

Value parameters

allowEmptyFiles

If empty file uploads are allowed (no matter if filename or file is empty)

Attributes

Inherited from:
PlayBodyParsers

Parse the content as multipart/form-data

Parse the content as multipart/form-data

Value parameters

maxLength

Max length (in bytes) allowed or returns EntityTooLarge HTTP response.

Attributes

Inherited from:
PlayBodyParsers

Parse the content as multipart/form-data

Parse the content as multipart/form-data

Attributes

Inherited from:
PlayBodyParsers

Store the body content in a RawBuffer.

Store the body content in a RawBuffer.

Attributes

Inherited from:
PlayBodyParsers
def raw(memoryThreshold: Long, maxLength: Long): BodyParser[RawBuffer]

Store the body content in a RawBuffer.

Store the body content in a RawBuffer.

Value parameters

memoryThreshold

If the content size is bigger than this limit, the content is stored as file.

Attributes

See also
Inherited from:
PlayBodyParsers

Store the body content into a temporary file.

Store the body content into a temporary file.

Attributes

Inherited from:
PlayBodyParsers

Store the body content into a temporary file.

Store the body content into a temporary file.

Value parameters

maxLength

Max length (in bytes) allowed or returns EntityTooLarge HTTP response.

Attributes

Inherited from:
PlayBodyParsers

Parse the body as text if the Content-Type is text/plain.

Parse the body as text if the Content-Type is text/plain.

Attributes

Inherited from:
PlayBodyParsers
def text(maxLength: Long): BodyParser[String]

Parse the body as text if the Content-Type is text/plain.

Parse the body as text if the Content-Type is text/plain.

If the charset is not explicitly declared, then the default "charset" parameter value is US-ASCII, per https://tools.ietf.org/html/rfc6657#section-4. Use tolerantText if more flexible character decoding is desired.

Value parameters

maxLength

Max length (in bytes) allowed or returns EntityTooLarge HTTP response.

Attributes

Inherited from:
PlayBodyParsers

Parse the body as form url encoded without checking the Content-Type.

Parse the body as form url encoded without checking the Content-Type.

Attributes

Inherited from:
PlayBodyParsers

Parse the body as Form url encoded without checking the Content-Type.

Parse the body as Form url encoded without checking the Content-Type.

Value parameters

maxLength

Max length (in bytes) allowed or returns EntityTooLarge HTTP response.

Attributes

Inherited from:
PlayBodyParsers
def tolerantJson[A](implicit reader: Reads[A]): BodyParser[A]

Parse the body as Json without checking the Content-Type, validating the result with the Json reader.

Parse the body as Json without checking the Content-Type, validating the result with the Json reader.

Type parameters

A

the type to read and validate from the body.

Value parameters

reader

a Json reader for type A.

Attributes

Inherited from:
PlayBodyParsers

Parse the body as Json without checking the Content-Type.

Parse the body as Json without checking the Content-Type.

Attributes

Inherited from:
PlayBodyParsers
def tolerantJson(maxLength: Long): BodyParser[JsValue]

Parse the body as Json without checking the Content-Type.

Parse the body as Json without checking the Content-Type.

Value parameters

maxLength

Max length (in bytes) allowed or returns EntityTooLarge HTTP response.

Attributes

Inherited from:
PlayBodyParsers

Parse the body as text without checking the Content-Type.

Parse the body as text without checking the Content-Type.

Attributes

Inherited from:
PlayBodyParsers
def tolerantText(maxLength: Long): BodyParser[String]

Parses the body as text without checking the Content-Type.

Parses the body as text without checking the Content-Type.

Will attempt to parse content with an explicit charset, but will fallback to UTF-8, ISO-8859-1, and finally US-ASCII if incorrect characters are detected.

Value parameters

maxLength

Max length (in bytes) allowed or returns EntityTooLarge HTTP response.

Attributes

Inherited from:
PlayBodyParsers

Parse the body as Xml without checking the Content-Type.

Parse the body as Xml without checking the Content-Type.

Attributes

Inherited from:
PlayBodyParsers
def tolerantXml(maxLength: Long): BodyParser[NodeSeq]

Parse the body as Xml without checking the Content-Type.

Parse the body as Xml without checking the Content-Type.

Value parameters

maxLength

Max length (in bytes) allowed or returns EntityTooLarge HTTP response.

Attributes

Inherited from:
PlayBodyParsers
def using[A](f: RequestHeader => BodyParser[A]): BodyParser[A]

Allows to choose the right BodyParser parser to use by examining the request headers.

Allows to choose the right BodyParser parser to use by examining the request headers.

Attributes

Inherited from:
BodyParserUtils
def when[A](predicate: RequestHeader => Boolean, parser: BodyParser[A], badResult: RequestHeader => Future[Result]): BodyParser[A]

Creates a conditional BodyParser.

Creates a conditional BodyParser.

Attributes

Inherited from:
BodyParserUtils

Parse the body as Xml if the Content-Type is application/xml, text/xml or application/XXX+xml.

Parse the body as Xml if the Content-Type is application/xml, text/xml or application/XXX+xml.

Attributes

Inherited from:
PlayBodyParsers
def xml(maxLength: Long): BodyParser[NodeSeq]

Parse the body as Xml if the Content-Type is application/xml, text/xml or application/XXX+xml.

Parse the body as Xml if the Content-Type is application/xml, text/xml or application/XXX+xml.

Value parameters

maxLength

Max length (in bytes) allowed or returns EntityTooLarge HTTP response.

Attributes

Inherited from:
PlayBodyParsers

Deprecated and Inherited methods

def multipartFormData[A](filePartHandler: () => A, maxLength: Long): BodyParser[MultipartFormData[A]]

Parse the content as multipart/form-data

Parse the content as multipart/form-data

Value parameters

filePartHandler

Handles file parts.

maxLength

Max length (in bytes) allowed or returns EntityTooLarge HTTP response.

Attributes

See also
Deprecated

Since 2.9.0. Use the overloaded multipartFormData method that takes the allowEmptyFiles flag.

Inherited from:
PlayBodyParsers

Inherited fields

Unlimited size.

Unlimited size.

Attributes

Inherited from:
PlayBodyParsers