Skip to content

Commit 068a28d

Browse files
abh1sardhslove
authored andcommitted
Configure org.eclipse.jetty.server.Request.maxFormKeys from server.properties and increase the default value (apache#10214)
1 parent 27c7216 commit 068a28d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

client/conf/server.properties.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ session.timeout=10
3232
# Max allowed API request payload/content size in bytes
3333
request.content.size=1048576
3434

35+
# Max allowed API request form keys
36+
request.max.form.keys=5000
37+
3538
# Options to configure and enable HTTPS on the management server
3639
#
3740
# For the management server to pick up these configuration settings, the configured

client/src/main/java/org/apache/cloudstack/ServerDaemon.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ public class ServerDaemon implements Daemon {
8282
private static final String ACCESS_LOG = "access.log";
8383
private static final String REQUEST_CONTENT_SIZE_KEY = "request.content.size";
8484
private static final int DEFAULT_REQUEST_CONTENT_SIZE = 1048576;
85+
private static final String REQUEST_MAX_FORM_KEYS_KEY = "request.max.form.keys";
86+
private static final int DEFAULT_REQUEST_MAX_FORM_KEYS = 5000;
8587

8688
////////////////////////////////////////////////////////
8789
/////////////// Server Configuration ///////////////////
@@ -94,6 +96,7 @@ public class ServerDaemon implements Daemon {
9496
private int httpsPort = 8443;
9597
private int sessionTimeout = 10;
9698
private int maxFormContentSize = DEFAULT_REQUEST_CONTENT_SIZE;
99+
private int maxFormKeys = DEFAULT_REQUEST_MAX_FORM_KEYS;
97100
private boolean httpsEnable = false;
98101
private String accessLogFile = "access.log";
99102
private String bindInterface = null;
@@ -141,6 +144,7 @@ public void init(final DaemonContext context) {
141144
setAccessLogFile(properties.getProperty(ACCESS_LOG, "access.log"));
142145
setSessionTimeout(Integer.valueOf(properties.getProperty(SESSION_TIMEOUT, "10")));
143146
setMaxFormContentSize(Integer.valueOf(properties.getProperty(REQUEST_CONTENT_SIZE_KEY, String.valueOf(DEFAULT_REQUEST_CONTENT_SIZE))));
147+
setMaxFormKeys(Integer.valueOf(properties.getProperty(REQUEST_MAX_FORM_KEYS_KEY, String.valueOf(DEFAULT_REQUEST_MAX_FORM_KEYS))));
144148
} catch (final IOException e) {
145149
logger.warn("Failed to read configuration from server.properties file", e);
146150
} finally {
@@ -192,6 +196,7 @@ public void start() throws Exception {
192196
// Extra config options
193197
server.setStopAtShutdown(true);
194198
server.setAttribute(ContextHandler.MAX_FORM_CONTENT_SIZE_KEY, maxFormContentSize);
199+
server.setAttribute(ContextHandler.MAX_FORM_KEYS_KEY, maxFormKeys);
195200

196201
// HTTPS Connector
197202
createHttpsConnector(httpConfig);
@@ -264,6 +269,7 @@ private Pair<SessionHandler,HandlerCollection> createHandlers() {
264269
webApp.setContextPath(contextPath);
265270
webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
266271
webApp.setMaxFormContentSize(maxFormContentSize);
272+
webApp.setMaxFormKeys(maxFormKeys);
267273

268274
// GZIP handler
269275
final GzipHandler gzipHandler = new GzipHandler();
@@ -366,4 +372,8 @@ public void setSessionTimeout(int sessionTimeout) {
366372
public void setMaxFormContentSize(int maxFormContentSize) {
367373
this.maxFormContentSize = maxFormContentSize;
368374
}
375+
376+
public void setMaxFormKeys(int maxFormKeys) {
377+
this.maxFormKeys = maxFormKeys;
378+
}
369379
}

0 commit comments

Comments
 (0)