Fixes #3856 - Different behaviour with maxFormContentSize=0 if Content-Length header is present/missing.
Changed the logic to lookup server attributes if there is no context. This fixes a failing test that was explicitly setting the server attributes after start. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
2488c9611f
commit
8418f56e94
|
@ -507,6 +507,11 @@ public class Request implements HttpServletRequest
|
|||
maxFormContentSize = contextHandler.getMaxFormContentSize();
|
||||
maxFormKeys = contextHandler.getMaxFormKeys();
|
||||
}
|
||||
else
|
||||
{
|
||||
maxFormContentSize = lookupServerAttribute(ContextHandler.MAX_FORM_CONTENT_SIZE_KEY, maxFormContentSize);
|
||||
maxFormKeys = lookupServerAttribute(ContextHandler.MAX_FORM_KEYS_KEY, maxFormKeys);
|
||||
}
|
||||
|
||||
int contentLength = getContentLength();
|
||||
if (maxFormContentSize >= 0 && contentLength > maxFormContentSize)
|
||||
|
@ -525,6 +530,16 @@ public class Request implements HttpServletRequest
|
|||
}
|
||||
}
|
||||
|
||||
private int lookupServerAttribute(String key, int dftValue)
|
||||
{
|
||||
Object attribute = _channel.getServer().getAttribute(key);
|
||||
if (attribute instanceof Number)
|
||||
return ((Number)attribute).intValue();
|
||||
else if (attribute instanceof String)
|
||||
return Integer.parseInt((String)attribute);
|
||||
return dftValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AsyncContext getAsyncContext()
|
||||
{
|
||||
|
|
|
@ -140,9 +140,11 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
|
|||
* for the attribute value.
|
||||
*/
|
||||
public static final String MANAGED_ATTRIBUTES = "org.eclipse.jetty.server.context.ManagedAttributes";
|
||||
private static final int NOT_INITIALIZED = -2;
|
||||
public static final int DEFAULT_MAX_FORM_CONTENT_SIZE = 200000;
|
||||
|
||||
public static final String MAX_FORM_KEYS_KEY = "org.eclipse.jetty.server.Request.maxFormKeys";
|
||||
public static final String MAX_FORM_CONTENT_SIZE_KEY = "org.eclipse.jetty.server.Request.maxFormContentSize";
|
||||
public static final int DEFAULT_MAX_FORM_KEYS = 1000;
|
||||
public static final int DEFAULT_MAX_FORM_CONTENT_SIZE = 200000;
|
||||
|
||||
/**
|
||||
* Get the current ServletContext implementation.
|
||||
|
@ -195,8 +197,8 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
|
|||
|
||||
private Logger _logger;
|
||||
private boolean _allowNullPathInfo;
|
||||
private int _maxFormKeys = NOT_INITIALIZED;
|
||||
private int _maxFormContentSize = NOT_INITIALIZED;
|
||||
private int _maxFormKeys = Integer.getInteger(MAX_FORM_KEYS_KEY, DEFAULT_MAX_FORM_KEYS);
|
||||
private int _maxFormContentSize = Integer.getInteger(MAX_FORM_CONTENT_SIZE_KEY, DEFAULT_MAX_FORM_CONTENT_SIZE);
|
||||
private boolean _compactPath = false;
|
||||
private boolean _usingSecurityManager = System.getSecurityManager() != null;
|
||||
|
||||
|
@ -785,12 +787,6 @@ public class ContextHandler extends ScopedHandler implements Attributes, Gracefu
|
|||
@Override
|
||||
protected void doStart() throws Exception
|
||||
{
|
||||
if (_maxFormKeys == NOT_INITIALIZED)
|
||||
_maxFormKeys = lookup("org.eclipse.jetty.server.Request.maxFormKeys", DEFAULT_MAX_FORM_KEYS);
|
||||
|
||||
if (_maxFormContentSize == NOT_INITIALIZED)
|
||||
_maxFormContentSize = lookup("org.eclipse.jetty.server.Request.maxFormContentSize", DEFAULT_MAX_FORM_CONTENT_SIZE);
|
||||
|
||||
_availability = Availability.STARTING;
|
||||
|
||||
if (_contextPath == null)
|
||||
|
|
Loading…
Reference in New Issue