What is the default max post content size in spring boot

Viewed 19

I am using Spring Boot application. When I do post request as below, I can able to pass content size of 5MB. As per the documentation here, default is 2MB. Let me the default size of post content.

Following are the specifications:

  1. Tomcat server (Default)
  2. WebMVC
  3. Embedded container

Request url: http://localhost:8080/store

Request body:

{
  "value": "test...." (length=5MB)
}
1 Answers

As this ticket shows there was/is some confusion on what the server.tomcat.max-http-form-post-size actually does. (Actually the previous naming but it provides some additional context!).

But in short it sets the maximum size of the request parameters for a POST request. Those parameters are only available for a form that is being submitted through POST. It doesn't apply to a JSON body being sent as the body of a request.

When using a multipart request you could limit this with the spring.servlet.multipart.max-request-size property, however this would require a multipart request instead of a simple application/json with a post.

For, at least, Tomcat there is no unified way of setting the maximum size of a request that is going to be accepted. However you could implement this yourself using a servlet filter and check the size (if available!) and either allow/disallow the processing.

Related