The documentation describes the following:
server.tomcat.max-http-post-size=2MB # Maximum size of the HTTP post content.
However this setting only affects post requests with FORM content, not all post requests. This can lead to confusion for myself and others (as per stackoverflow questions). A more precise description would be helpful, such as:
server.tomcat.max-http-post-size=2MB # Maximum size of the FORM content in an HTTP post request. Non-FORM post requests are unaffected by this property.
Comment From: sbrannen
@fg8dgrdh, this is the issue tracker for the core Spring Framework.
For Spring Boot, please use the following issue tracker: https://github.com/spring-projects/spring-boot/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc
Or perhaps @snicoll or @philwebb can transfer this issue.
Comment From: snicoll
Or perhaps @snicoll or @philwebb can transfer this issue.
Yes we can but please give us a bit of time to act on it before closing.
Comment From: rhamedy
@snicoll can I make a PR for this?
Comment From: snicoll
Thanks for the offer. The issue has been triaged and isn't assigned at the moment so feel free to do it
Comment From: rhamedy
Updated the Javadoc in the ServerProperties.java
, not sure if there is anything else that needs to be done.
Comment From: wilkinsona
We have a similar problem with Jetty. The property, server.jetty.max-http-post-size
, is described as "Maximum size of the HTTP post or put content" but it maps onto setMaxFormContentSize
and is specific to POSTed form content. As far as I can tell, content sent as a PUT
is not affected.
Undertow is also affected but the problem is different. The property, server.undertow.max-http-post-size
, is described as "Maximum size of the HTTP post content. When the value is -1, the default, the size is unlimited". It maps onto Undertow.MAX_ENTITY_SIZE
which isn't limited to form content but also isn't limited to POST requests. The property would be better named something like server.undertow.max-http-entity-size
.
Given that we need to deprecate server.undertow.max-http-post-size
and provide a replacement, I wonder if we should do similar for server.jetty.max-http-post-size
and server.tomcat.max-http-post-size
. max-http-form-post-size
would perhaps be a more accurate name.
Comment From: fg8dgrdh
@sbrannen Sorry about opening the issue in the wrong project, I'll try and be more careful next time.
@snicoll Thanks for transferring the ticket, I appreciate it.
@rhamedy Thanks for the PR!
@wilkinsona I like the max-http-form-post-size idea
Comment From: rhamedy
IMO, deprecation seem to be the more suiting fix based on wikinsona’s explanation.
Regardless, I would be happy to re-purpose the PR should the scope of this issue change 👌
Comment From: wilkinsona
https://github.com/spring-projects/spring-boot/issues/18555 is related to, or maybe even a duplicate of, the Undertow aspects of this.
Comment From: wilkinsona
We're going to introduce new properties in 2.1.x:
server.jetty.max-http-form-post-size
server.tomcat.max-http-form-post-size
We'll deprecate the old, misleadingly named properties at the same time.
We'll use #18555 to figure out the Undertow side of this once we know if the multipart config element behaviour is intentional or a bug.
Comment From: rhamedy
@wilkinsona aren't they already named that way? 😕
// server.jetty.max-http-post-size
private DataSize maxHttpPostSize = DataSize.ofBytes(200000);
// server.tomcat.max-http-post-size
private DataSize maxHttpPostSize = DataSize.ofMegabytes(2); //tomcat
I could update my PR and base it off 2.1.x
branch 🙂
Comment From: wilkinsona
Sorry, I meant to include form
in the new names. I've updated my comment above.
Comment From: wilkinsona
Closing in favour of #18566.
Comment From: HimanshuChugh2
Hello,
i have tried writing this
@Bean
public TomcatServletWebServerFactory tomcatEmbedded() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
tomcat.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> {
if ((connector.getProtocolHandler() instanceof AbstractHttp11Protocol<?>)) {
//-1 means unlimited
((AbstractHttp11Protocol<?>) connector.getProtocolHandler()).setMaxSwallowSize(100000000);
((AbstractHttp11Protocol<?>) connector.getProtocolHandler()).setMaxSavePostSize(100000000);
}
});
return tomcat;
}
and this in application.properties file
# Server properties
server.tomcat.max-http-post-size=100000000
server.tomcat.max-swallow-size=100000000
it is still not passing text(json which includes base64 text too) of more then 2MB from html to controller.
Why is this happening?
Please help
Comment From: wilkinsona
Unfortunately, I can't say why it's happening from a couple of code snippets. We need to see more of your application – for example exactly how the browser is sending the information to the controller – but a closed issue isn't the right place. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. If you believe that you've found a bug, and you would like us to spend some more time investigating, please open a new issue and spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to the issue that you open.
Comment From: HimanshuChugh2
Hello sir @wilkinsona ,
i have created a new issue(https://github.com/spring-projects/spring-boot/issues/22724), kindly requesting you to take a look.
Thank you so much in advance.