Tomcat maxpostsize value ignored with XMLHttpRequest?

橙三吉。 提交于 2019-12-23 03:12:08

问题


I am developing a web application with Spring 3 and jquery and i am using an ajax upload script to send files to the server (Tomcat 7.0.22). A file is posted to the server with a content-type of application/octet-stream and the server parses it fine as a byte array. However although i have even explicitly set in the tomcat configuration the value of maxpostsize to 2097152, this setting appears to have no effect at all. For example i am able to upload files (locally) large enough (> 1 GB) to crash the server (out of 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's connector config

 <Service name="Catalina">

<Connector port="8080" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           redirectPort="8443" 
           maxPostSize="2097152"/>

回答1:


Although this is an old question:

As can be seen in Request.java, maxPostSize is taken into account only for the "application/x-www-form-urlencoded" content type and is not affected by how the request is made ("normal" vs. xhr).



来源:https://stackoverflow.com/questions/7696197/tomcat-maxpostsize-value-ignored-with-xmlhttprequest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!