I have this configured in my server.xml file
<Connector URIEncoding="UTF-8" connectionTimeout="20000" maxHttpHeaderSize="65536" **maxPostSize="1024"** port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
However, requests more than 1 KB pass as if maxPostSize is never set. Can anyone suggest what can cause that?
Another thing, I would like to know how to make a custom http reply from tomcat if the post size is more than 1 KB
UPDATE Since I have been for so long in this issue. I had the opportunity to look at the source code for tomcat to check what is happening here exactly: click here
I noticed from lines 2541 till 2550, they are using getContentLength() although the documentation says "maxPostSize: The maximum size in bytes". How come could this be in bytes? It looks more to characters count to me and it can be done in servlet side. Can someone explain what I am missing here?
maxPostSize. The maximum size in bytes of the POST which will be handled by the container FORM URL parameter parsing. The limit can be disabled by setting this attribute to a value less than or equal to 0. If not specified, this attribute is set to 2097152 (2 megabytes).
maxHttpHeaderSize. The maximum size of the request and response HTTP header, specified in bytes. If not specified, this attribute is set to 8192 (8 KB). maxKeepAliveRequests. The maximum number of HTTP requests which can be pipelined until the connection is closed by the server.
In a Spring Boot application, the max HTTP header size is configured using server. max-http-header-size. The actual default value for Tomcat and Jetty is 8kB, and the default value for Undertow is 1MB.
acceptCount -- The maximum queue length for incoming connection requests when all possible request processing threads are in use. Any requests received when the queue is full will be refused. The default value is 100.
According to tomcat doc the maxPostSize is 2M.
The maximum size in bytes of the POST which will be handled by the container FORM URL parameter parsing. The limit can be disabled by setting this attribute to a value less than zero. If not specified, this attribute is set to 2097152 (2 megabytes). Note that the FailedRequestFilter can be used to reject requests that exceed this limit.
If you would to change the default values then change in the file location below:
$CATALINA_HOME/conf/server.xml
Example:
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
maxPostSize="6291456" />
The size in bytes 6291456*(1024*1024)=6M
Note: Please make sure you restart the server after making the changes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With