Leonardo Vannucci
2018-09-19 c4cb974be197acfe06dc06359c25d04611fa47f2
dg1cloud-core/src/main/java/it/digione/dg1cloud/app/Dg1cloudCoreApplication.java
....@@ -1,15 +1,25 @@
11 package it.digione.dg1cloud.app;
22
3
+import org.apache.catalina.connector.Connector;
4
+import org.apache.coyote.http11.AbstractHttp11Protocol;
5
+import org.springframework.beans.factory.annotation.Value;
36 import org.springframework.boot.SpringApplication;
47 import org.springframework.boot.autoconfigure.SpringBootApplication;
58 import org.springframework.boot.builder.SpringApplicationBuilder;
9
+import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
610 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
11
+import org.springframework.context.annotation.Bean;
712 import org.springframework.context.annotation.ComponentScan;
13
+import org.springframework.context.annotation.Configuration;
814
915 @ComponentScan(basePackages="it.digione.dg1cloud")
16
+@Configuration
1017 @SpringBootApplication
1118 public class Dg1cloudCoreApplication extends SpringBootServletInitializer {
1219
20
+ @Value("${tomcat.MaxSwallowSize}")
21
+ private int maxFileSize;
22
+
1323 public static void main(String[] args) {
1424 SpringApplication.run(Dg1cloudCoreApplication.class, args);
1525 }
....@@ -18,4 +28,20 @@
1828 protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
1929 return application.sources(Dg1cloudCoreApplication.class);
2030 }
31
+
32
+ @Bean
33
+ public TomcatServletWebServerFactory containerFactory() {
34
+ return new TomcatServletWebServerFactory() {
35
+ protected void customizeConnector(Connector connector) {
36
+ int maxSize = maxFileSize * 1024 * 1024 * 10;
37
+ super.customizeConnector(connector);
38
+ connector.setMaxPostSize(maxSize);
39
+ connector.setMaxSavePostSize(maxSize);
40
+ if (connector.getProtocolHandler() instanceof AbstractHttp11Protocol) {
41
+ ((AbstractHttp11Protocol <?>) connector.getProtocolHandler()).setMaxSwallowSize(-1);
42
+ logger.info("Set MaxSwallowSize "+ maxSize);
43
+ }
44
+ }
45
+ };
46
+ }
2147 }