结论两句话:
tomcat知道自己处理不了了,什么也不干过去了
jett知道自己处理不了了,抛个IllegalStateException出来通知一下
jetty默认允许的content-length=200×1000
org.eclipse.jetty.server.Request
public void extractParameters() { if (_baseParameters == null) _baseParameters = new MultiMap(16); if (_paramsExtracted) { if (_parameters==null) _parameters=_baseParameters; return; } _paramsExtracted = true;.... // handle any _content. String encoding = getCharacterEncoding(); String content_type = getContentType(); if (content_type != null && content_type.length() > 0) { content_type = HttpFields.valueParameters(content_type, null); if (MimeTypes.FORM_ENCODED.equalsIgnoreCase(content_type) && (HttpMethods.POST.equals(getMethod()) || HttpMethods.PUT.equals(getMethod()))) { int content_length = getContentLength(); if (content_length != 0) { try { int maxFormContentSize=-1; if (_context!=null) maxFormContentSize=_context.getContextHandler().getMaxFormContentSize(); else { Integer size = (Integer)_connection.getConnector().getServer().getAttribute("org.eclipse.jetty.server.Request.maxFormContentSize"); if (size!=null) maxFormContentSize =size.intValue(); } if (content_length>maxFormContentSize && maxFormContentSize > 0) { throw new IllegalStateException("Form too large"+content_length+">"+maxFormContentSize); } InputStream in = getInputStream(); // Add form params to query params UrlEncoded.decodeTo(in, _baseParameters, encoding,content_length<0?maxFormContentSize:-1); } catch (IOException e) { if (Log.isDebugEnabled()) Log.warn(e); else Log.warn(e.toString()); } } } }.... } }
jetty修改content-length方法
... ... org.eclipse.jetty.server.Request.maxFormContentSize
启动方式
java -jar start.jar -Dorg.eclipse.jetty.server.Request.maxFormContentSize=600000
还有另外一种配置方式
org.eclipse.jetty.server.Request.maxFormContentSize 400000
tomcat默认允许的content-length=2×1024×1024
org.apache.catalina.connector.Request
protected void parseParameters() {...... if (!("application/x-www-form-urlencoded".equals(contentType))) return; int len = getContentLength(); if (len > 0) { int maxPostSize = connector.getMaxPostSize(); // tomcat默认大小2*1024*1024 if ((maxPostSize > 0) && (len > maxPostSize)) { if (context.getLogger().isDebugEnabled()) { context.getLogger().debug( sm.getString("coyoteRequest.postTooLarge")); } return; // 内容超长则直接返回,jetty会抛出IllegalStateException //Parameters 对象没有内容 }.....}public MapgetParameterMap() { if (parameterMap.isLocked()) return parameterMap; Enumeration enumeration = getParameterNames(); while (enumeration.hasMoreElements()) { String name = enumeration.nextElement(); String[] values = getParameterValues(name); parameterMap.put(name, values); } parameterMap.setLocked(true); return parameterMap;}public Enumeration getParameterNames() { if (!parametersParsed) parseParameters(); return coyoteRequest.getParameters().getParameterNames();}