Tomcat's maxpostsize value is ignored using XMLHttpRequest?

I am developing a web application with Spring 3 and jquery and I am using ajax upload script to upload files to the server (Tomcat 7.0.22). The file is sent to the server with the content type application/octet-stream and the server parses it as a byte array. However, although I even explicitly set the value from maxpostsize to 2097152 in the tomcat configuration, this option has no effect. For example, I can upload files (locally) large enough (> 1 GB) to crash the server (from memory). Here are the request headers from firebug:

 Host localhost:8080 User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1 Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language en-us,en;q=0.5 Accept-Encoding gzip, deflate Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 Connection keep-alive X-Requested-With XMLHttpRequest X-File-Name some-pdf.pdf Content-Type application/octet-stream Referer http://localhost:8080/myapp/ Content-Length 9369597 Cookie JSESSIONID=F237BA8176D158A297BAFA7F57A98A5F; Pragma no-cache Cache-Control no-cache 

Here is the Tomcat connector configuration

  <Service name="Catalina"> <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" maxPostSize="2097152"/> 
+1
post tomcat
source share
1 answer

Although this is an old question:

As can be seen from Request.java , maxPostSize is only considered for the "application / x-www-form-urlencoded" content type and does not depend on how the request is executed ("normal" versus xhr).

+4
source

All Articles