[2.0.3-java] Can't POST any JSON > 100kb

465 views
Skip to first unread message

Eric Jain

unread,
Aug 27, 2012, 5:17:28 PM8/27/12
to play-fr...@googlegroups.com
To increase the default limit (100kb?), I added a maxLength to the controller:

  @BodyParser.Of(value = BodyParser.Json.class, maxLength = 1024 * 1024) // 1mb
  public static Result post(String id) {
    JsonNode node = request().body().asJson(); // null!
    ...
  }

No luck; requests with bodies that are larger than 100kb still return null. The setting does work to reduce the maxLength to less than 100kb, though it's strange that instead of a 400 Bad Request, Play simply returns null for the body. Is that how this is intended to work?

I also added this to the application.conf (wild guess):

  parsers.json.maxLength=1mb

Still no luck. Any ideas?

Eric Jain

unread,
Aug 27, 2012, 5:30:12 PM8/27/12
to play-fr...@googlegroups.com
Setting parsers.text.maxLength=1M appears to work. Looks like the value of this setting can't be increased (only reduced) at the controller level?

James Roper

unread,
Aug 28, 2012, 11:15:01 AM8/28/12
to play-fr...@googlegroups.com
This is probably a bug.  Please report it.

Eric Jain

unread,
Aug 28, 2012, 11:47:30 AM8/28/12
to play-fr...@googlegroups.com
On Tue, Aug 28, 2012 at 8:15 AM, James Roper <jro...@gmail.com> wrote:
> This is probably a bug. Please report it.

https://play.lighthouseapp.com/projects/82401-play-20/tickets/709-bodyparserof-maxlength-is-ignored

What about requests with bodies that are too large returning null?
Shouldn't Play catch these and return 400 Bad Request, rather than
continuing with a null request body?

James Roper

unread,
Aug 29, 2012, 1:42:25 AM8/29/12
to play-fr...@googlegroups.com
If the body is too large, then request().body.isMaxSizeExceeded() will return true.

Perhaps it might be a good idea to add functionality to automatically return a 413 status code (request entity too large) in future, but it would have to be configurable.
Reply all
Reply to author
Forward
0 new messages