How do I limit the size of request body in tomcat 7. I expect the body as raw type of application/json. I have already tried setting maxPostSize variable in tomcat server.xml, but that doesn't work. I tried setting maxPostSize to a small value (100) but am still able to post a bigger request.
Asked
Active
Viewed 2,581 times
2
-
care to clarify what that doesn't work means? Did you try setting it to some absurdly low value and post a much bigger request and didn't get an error message? – Foon Nov 19 '15 at 14:41
-
1Yes. I set the vakye to 100 but am still able to post a bigger request – freeborn Nov 19 '15 at 18:29
1 Answers
1
Looks like other than multipart upload request, there is no restriction imposed out of box on payload size.
In case of spring boot following properties has no impact with respect to request payload for other than multipart upload request. (e.g. request body that contains json payload)
spring.http.multipart.max-file-size
spring.http.multipart.max-request-size
server.tomcat.max-http-post-size
Workaround is to implement your own filter with required max size restriction.
Following is reference link, and depends on content-length header set by client.
Spring boot Embedded Tomcat "application/json" post request restriction to 10KB

Snehal Patel
- 819
- 6
- 9