397130 maxFormContentSize set in jetty.xml is ignored

This commit is contained in:
Jan Bartel 2013-01-07 20:10:54 +11:00
parent a4c547d61f
commit 3265c334cb
2 changed files with 33 additions and 9 deletions

View File

@ -255,18 +255,42 @@ public class Request implements HttpServletRequest
maxFormContentSize = _context.getContextHandler().getMaxFormContentSize(); maxFormContentSize = _context.getContextHandler().getMaxFormContentSize();
maxFormKeys = _context.getContextHandler().getMaxFormKeys(); maxFormKeys = _context.getContextHandler().getMaxFormKeys();
} }
else
if (maxFormContentSize < 0)
{ {
Number size = (Number)_connection.getConnector().getServer() Object obj = _connection.getConnector().getServer().getAttribute("org.eclipse.jetty.server.Request.maxFormContentSize");
.getAttribute("org.eclipse.jetty.server.Request.maxFormContentSize"); if (obj == null)
maxFormContentSize = size == null?200000:size.intValue(); maxFormContentSize = 200000;
Number keys = (Number)_connection.getConnector().getServer().getAttribute("org.eclipse.jetty.server.Request.maxFormKeys"); else if (obj instanceof Number)
maxFormKeys = keys == null?1000:keys.intValue(); {
Number size = (Number)obj;
maxFormContentSize = size.intValue();
}
else if (obj instanceof String)
{
maxFormContentSize = Integer.valueOf((String)obj);
}
}
if (maxFormKeys < 0)
{
Object obj = _connection.getConnector().getServer().getAttribute("org.eclipse.jetty.server.Request.maxFormKeys");
if (obj == null)
maxFormKeys = 1000;
else if (obj instanceof Number)
{
Number keys = (Number)obj;
maxFormKeys = keys.intValue();
}
else if (obj instanceof String)
{
maxFormKeys = Integer.valueOf((String)obj);
}
} }
if (content_length > maxFormContentSize && maxFormContentSize > 0) if (content_length > maxFormContentSize && maxFormContentSize > 0)
{ {
throw new IllegalStateException("Form too large" + content_length + ">" + maxFormContentSize); throw new IllegalStateException("Form too large " + content_length + ">" + maxFormContentSize);
} }
InputStream in = getInputStream(); InputStream in = getInputStream();

View File

@ -129,8 +129,8 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
private EventListener[] _eventListeners; private EventListener[] _eventListeners;
private Logger _logger; private Logger _logger;
private boolean _allowNullPathInfo; private boolean _allowNullPathInfo;
private int _maxFormKeys = Integer.getInteger("org.eclipse.jetty.server.Request.maxFormKeys",1000).intValue(); private int _maxFormKeys = Integer.getInteger("org.eclipse.jetty.server.Request.maxFormKeys",-1).intValue();
private int _maxFormContentSize = Integer.getInteger("org.eclipse.jetty.server.Request.maxFormContentSize",200000).intValue(); private int _maxFormContentSize = Integer.getInteger("org.eclipse.jetty.server.Request.maxFormContentSize",-1).intValue();
private boolean _compactPath = false; private boolean _compactPath = false;
private boolean _aliases = false; private boolean _aliases = false;