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
UPDATESince 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:Request.java
docjar.com (dead link) (Request.java
docjar.com (archived version), Request.jar
(Github))
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?
/** * Parse request parameters. */protected void parseParameters() { ... int len = getContentLength(); if (len > 0) { int maxPostSize = connector.getMaxPostSize(); if ((maxPostSize > 0) && (len > maxPostSize)) { if (context.getLogger().isDebugEnabled()) { context.getLogger().debug( sm.getString("coyoteRequest.postTooLarge")); } return; }