2626import java .net .URL ;
2727import java .util .Properties ;
2828
29- import com .cloud .utils .Pair ;
30- import com .cloud .utils .server .ServerProperties ;
3129import org .apache .commons .daemon .Daemon ;
3230import org .apache .commons .daemon .DaemonContext ;
31+ import org .apache .commons .lang3 .StringUtils ;
32+ import org .apache .log4j .Logger ;
3333import org .eclipse .jetty .jmx .MBeanContainer ;
3434import org .eclipse .jetty .server .ForwardedRequestCustomizer ;
3535import org .eclipse .jetty .server .HttpConfiguration ;
4040import org .eclipse .jetty .server .Server ;
4141import org .eclipse .jetty .server .ServerConnector ;
4242import org .eclipse .jetty .server .SslConnectionFactory ;
43+ import org .eclipse .jetty .server .handler .ContextHandler ;
4344import org .eclipse .jetty .server .handler .HandlerCollection ;
4445import org .eclipse .jetty .server .handler .MovedContextHandler ;
4546import org .eclipse .jetty .server .handler .RequestLogHandler ;
5051import org .eclipse .jetty .util .thread .QueuedThreadPool ;
5152import org .eclipse .jetty .util .thread .ScheduledExecutorScheduler ;
5253import org .eclipse .jetty .webapp .WebAppContext ;
53- import org .apache .log4j .Logger ;
5454
55+ import com .cloud .utils .Pair ;
5556import com .cloud .utils .PropertiesUtil ;
56- import org . apache . commons . lang3 . StringUtils ;
57+ import com . cloud . utils . server . ServerProperties ;
5758
5859/***
5960 * The ServerDaemon class implements the embedded server, it can be started either
@@ -79,6 +80,8 @@ public class ServerDaemon implements Daemon {
7980 private static final String KEYSTORE_PASSWORD = "https.keystore.password" ;
8081 private static final String WEBAPP_DIR = "webapp.dir" ;
8182 private static final String ACCESS_LOG = "access.log" ;
83+ private static final String REQUEST_CONTENT_SIZE_KEY = "request.content.size" ;
84+ private static final int DEFAULT_REQUEST_CONTENT_SIZE = 1048576 ;
8285
8386 ////////////////////////////////////////////////////////
8487 /////////////// Server Configuration ///////////////////
@@ -90,6 +93,7 @@ public class ServerDaemon implements Daemon {
9093 private int httpPort = 8080 ;
9194 private int httpsPort = 8443 ;
9295 private int sessionTimeout = 30 ;
96+ private int maxFormContentSize = DEFAULT_REQUEST_CONTENT_SIZE ;
9397 private boolean httpsEnable = false ;
9498 private String accessLogFile = "access.log" ;
9599 private String bindInterface = null ;
@@ -136,6 +140,7 @@ public void init(final DaemonContext context) {
136140 setWebAppLocation (properties .getProperty (WEBAPP_DIR ));
137141 setAccessLogFile (properties .getProperty (ACCESS_LOG , "access.log" ));
138142 setSessionTimeout (Integer .valueOf (properties .getProperty (SESSION_TIMEOUT , "30" )));
143+ setMaxFormContentSize (Integer .valueOf (properties .getProperty (REQUEST_CONTENT_SIZE_KEY , String .valueOf (DEFAULT_REQUEST_CONTENT_SIZE ))));
139144 } catch (final IOException e ) {
140145 LOG .warn ("Failed to read configuration from server.properties file" , e );
141146 } finally {
@@ -186,6 +191,7 @@ public void start() throws Exception {
186191
187192 // Extra config options
188193 server .setStopAtShutdown (true );
194+ server .setAttribute (ContextHandler .MAX_FORM_CONTENT_SIZE_KEY , maxFormContentSize );
189195
190196 // HTTPS Connector
191197 createHttpsConnector (httpConfig );
@@ -257,6 +263,7 @@ private Pair<SessionHandler,HandlerCollection> createHandlers() {
257263 final WebAppContext webApp = new WebAppContext ();
258264 webApp .setContextPath (contextPath );
259265 webApp .setInitParameter ("org.eclipse.jetty.servlet.Default.dirAllowed" , "false" );
266+ webApp .setMaxFormContentSize (maxFormContentSize );
260267
261268 // GZIP handler
262269 final GzipHandler gzipHandler = new GzipHandler ();
@@ -355,4 +362,8 @@ public void setWebAppLocation(String webAppLocation) {
355362 public void setSessionTimeout (int sessionTimeout ) {
356363 this .sessionTimeout = sessionTimeout ;
357364 }
365+
366+ public void setMaxFormContentSize (int maxFormContentSize ) {
367+ this .maxFormContentSize = maxFormContentSize ;
368+ }
358369}
0 commit comments