Tomcat的maxpostsize值被XMLHttpRequest忽略了吗? [英] Tomcat maxpostsize value ignored with XMLHttpRequest?

查看:91
本文介绍了Tomcat的maxpostsize值被XMLHttpRequest忽略了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Spring 3和jquery开发一个Web应用程序,并且正在使用ajax上传脚本将文件发送到服务器(Tomcat 7.0.22).文件以application/octet-stream的内容类型发布到服务器 然后服务器将其解析为字节数组.但是,尽管我甚至已经在tomcat配置中将maxpostsize的值显式设置为2097152,但此设置似乎完全无效.例如,我能够上传(本地)足够大(> 1 GB)的文件以使服务器崩溃(内存不足).这是firebug的请求标头:

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

这是Tomcat的连接器配置

Here is the Tomcat's connector config

 <Service name="Catalina">

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

推荐答案

尽管这是一个老问题:

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).

这篇关于Tomcat的maxpostsize值被XMLHttpRequest忽略了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆