0

I want to limit the size of accepted application/json http request bodys in post method for certain controller/method. So that it is not possible to send multiple megabytes of json to my application, which are then processed and make my app run for a long time.

I know about properties like maxSwallowSize and maxPostSize but as far as I understood this methods sets size for methods in whole project.

Ezaz09
  • 1
  • Tomcat has settings you can put in the server.xml for post and get sizes, but with the client itself, it depends what API the client uses e.g. JavaScript, or intranet proprietary JavaScript or an app E.t.c. seems like you may need to custom process and measure for accepting. – Samuel Marchant Apr 24 '23 at 11:37
  • Please provide enough code so others can better understand or reproduce the problem. – Community Apr 25 '23 at 08:42

1 Answers1

0

You can create a filter that checks for content length. Please refer to this answer here