c

play.api.mvc

DefaultPlayBodyParsers

class DefaultPlayBodyParsers extends PlayBodyParsers

Source
BodyParsers.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. DefaultPlayBodyParsers
  2. PlayBodyParsers
  3. BodyParserUtils
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new DefaultPlayBodyParsers(config: ParserConfiguration, errorHandler: HttpErrorHandler, materializer: Materializer, temporaryFileCreator: TemporaryFileCreator)
    Annotations
    @Inject()

Value Members

  1. def DefaultAllowEmptyFileUploads: Boolean

    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
    Definition Classes
    PlayBodyParsers
  2. def DefaultMaxDiskLength: Long

    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
    Definition Classes
    PlayBodyParsers
  3. def DefaultMaxTextLength: Long

    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
    Definition Classes
    PlayBodyParsers
  4. val UNLIMITED: Long

    Unlimited size.

    Unlimited size.

    Definition Classes
    PlayBodyParsers
  5. def anyContent(maxLength: Option[Long]): [AnyContent]

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

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

    Definition Classes
    PlayBodyParsers
  6. def anyContent: [AnyContent]

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

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

    Definition Classes
    PlayBodyParsers
  7. def byteString: BodyParser[ByteString]

    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.

    Definition Classes
    PlayBodyParsers
  8. 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.

    maxLength

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

    Definition Classes
    PlayBodyParsers
  9. val config: ParserConfiguration
    Definition Classes
    PlayBodyParsers
  10. def default(maxLength: Option[Long]): [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.

    Definition Classes
    PlayBodyParsers
  11. def default: [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.

    Definition Classes
    PlayBodyParsers
  12. def defaultBodyParser: [AnyContent]
    Definition Classes
    PlayBodyParsers
  13. def empty: BodyParser[Unit]

    Don't parse the body content.

    Don't parse the body content.

    Definition Classes
    BodyParserUtils
  14. def error[A](result: Future[Result]): BodyParser[A]

    A body parser that always returns an error.

    A body parser that always returns an error.

    Definition Classes
    BodyParserUtils
  15. val errorHandler: HttpErrorHandler
    Definition Classes
    PlayBodyParsers
  16. def file(to: File): [File]

    Store the body content into a file.

    Store the body content into a file.

    to

    The file used to store the content.

    Definition Classes
    PlayBodyParsers
  17. def file(to: File, maxLength: Long): [File]

    Store the body content into a file.

    Store the body content into a file.

    to

    The file used to store the content.

    maxLength

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

    Definition Classes
    PlayBodyParsers
  18. 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.

    Definition Classes
    BodyParserUtils
  19. def form[A](form: Form[A], maxLength: Option[Long] = None, onErrors: (Form[A]) => Result = (_: Form[A]) => Results.BadRequest): 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}!")
    }
    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

    Definition Classes
    PlayBodyParsers
  20. def formBinding(maxChars: Long = DefaultMaxTextLength, maxDepth: Int = Form.FromJsonMaxDepth): FormBinding
    Definition Classes
    PlayBodyParsers
  21. def formUrlEncoded: BodyParser[Map[String, Seq[String]]]

    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.

    Definition Classes
    PlayBodyParsers
  22. def formUrlEncoded(maxLength: Long): BodyParser[Map[String, Seq[String]]]

    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.

    maxLength

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

    Definition Classes
    PlayBodyParsers
  23. def ignore[A](body: A): BodyParser[A]
    Definition Classes
    BodyParserUtils
  24. 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.

    A

    the type to read and validate from the body.

    reader

    a Json reader for type A.

    Definition Classes
    PlayBodyParsers
  25. def json: [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.

    Definition Classes
    PlayBodyParsers
  26. def json(maxLength: Long): [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.

    maxLength

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

    Definition Classes
    PlayBodyParsers
  27. val materializer: Materializer
    Definition Classes
    PlayBodyParsers
  28. 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.

    maxLength

    The max length allowed

    parser

    The BodyParser to wrap

    Definition Classes
    BodyParserUtils
  29. def multipartFormData[A](filePartHandler: FilePartHandler[A], maxLength: Long = DefaultMaxDiskLength, allowEmptyFiles: Boolean = DefaultAllowEmptyFileUploads): [MultipartFormData[A]]

    Parse the content as multipart/form-data

    Parse the content as multipart/form-data

    filePartHandler

    Handles file parts.

    maxLength

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

    allowEmptyFiles

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

    Definition Classes
    PlayBodyParsers
    See also

    DefaultMaxDiskLength

    Results.EntityTooLarge

  30. def multipartFormData(maxLength: Long, allowEmptyFiles: Boolean): [[TemporaryFile]]

    Parse the content as multipart/form-data

    Parse the content as multipart/form-data

    maxLength

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

    allowEmptyFiles

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

    Definition Classes
    PlayBodyParsers
  31. def multipartFormData(allowEmptyFiles: Boolean): [[TemporaryFile]]

    Parse the content as multipart/form-data

    Parse the content as multipart/form-data

    allowEmptyFiles

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

    Definition Classes
    PlayBodyParsers
  32. def multipartFormData(maxLength: Long): [[TemporaryFile]]

    Parse the content as multipart/form-data

    Parse the content as multipart/form-data

    maxLength

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

    Definition Classes
    PlayBodyParsers
  33. def multipartFormData: [[TemporaryFile]]

    Parse the content as multipart/form-data

    Parse the content as multipart/form-data

    Definition Classes
    PlayBodyParsers
  34. def raw: [RawBuffer]

    Store the body content in a RawBuffer.

    Store the body content in a RawBuffer.

    Definition Classes
    PlayBodyParsers
  35. def raw(memoryThreshold: Long = DefaultMaxTextLength, maxLength: Long = DefaultMaxDiskLength): [RawBuffer]

    Store the body content in a RawBuffer.

    Store the body content in a RawBuffer.

    memoryThreshold

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

    Definition Classes
    PlayBodyParsers
    See also

    DefaultMaxDiskLength

    Results.EntityTooLarge

  36. def temporaryFile: [TemporaryFile]

    Store the body content into a temporary file.

    Store the body content into a temporary file.

    Definition Classes
    PlayBodyParsers
  37. def temporaryFile(maxLength: Long): [TemporaryFile]

    Store the body content into a temporary file.

    Store the body content into a temporary file.

    maxLength

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

    Definition Classes
    PlayBodyParsers
  38. val temporaryFileCreator: TemporaryFileCreator
    Definition Classes
    PlayBodyParsers
  39. def text: 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.

    Definition Classes
    PlayBodyParsers
  40. 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.

    maxLength

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

    Definition Classes
    PlayBodyParsers
  41. def tolerantFormUrlEncoded: BodyParser[Map[String, Seq[String]]]

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

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

    Definition Classes
    PlayBodyParsers
  42. def tolerantFormUrlEncoded(maxLength: Long): BodyParser[Map[String, Seq[String]]]

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

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

    maxLength

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

    Definition Classes
    PlayBodyParsers
  43. 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.

    A

    the type to read and validate from the body.

    reader

    a Json reader for type A.

    Definition Classes
    PlayBodyParsers
  44. def tolerantJson: [JsValue]

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

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

    Definition Classes
    PlayBodyParsers
  45. def tolerantJson(maxLength: Long): [JsValue]

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

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

    maxLength

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

    Definition Classes
    PlayBodyParsers
  46. def tolerantText: BodyParser[String]

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

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

    Definition Classes
    PlayBodyParsers
  47. 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.

    maxLength

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

    Definition Classes
    PlayBodyParsers
  48. def tolerantXml: BodyParser[NodeSeq]

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

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

    Definition Classes
    PlayBodyParsers
  49. 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.

    maxLength

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

    Definition Classes
    PlayBodyParsers
  50. def using[A](f: () => 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.

    Definition Classes
    BodyParserUtils
  51. def when[A](predicate: (RequestHeader) => Boolean, parser: BodyParser[A], badResult: (RequestHeader) => Future[Result]): BodyParser[A]

    Creates a conditional BodyParser.

    Creates a conditional BodyParser.

    Definition Classes
    BodyParserUtils
  52. def xml: 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.

    Definition Classes
    PlayBodyParsers
  53. 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.

    maxLength

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

    Definition Classes
    PlayBodyParsers

Deprecated Value Members

  1. def multipartFormData[A](filePartHandler: FilePartHandler[A], maxLength: Long): [MultipartFormData[A]]

    Parse the content as multipart/form-data

    Parse the content as multipart/form-data

    filePartHandler

    Handles file parts.

    maxLength

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

    Definition Classes
    PlayBodyParsers
    Annotations
    @deprecated
    Deprecated

    (Since version 2.9.0) Use the overloaded multipartFormData method that takes the allowEmptyFiles flag

    See also

    DefaultMaxDiskLength

    Results.EntityTooLarge