| .. | .. |
|---|
| 1 | 1 | package it.digione.dg1cloud.app; |
|---|
| 2 | 2 | |
|---|
| 3 | +import org.apache.catalina.connector.Connector; |
|---|
| 4 | +import org.apache.coyote.http11.AbstractHttp11Protocol; |
|---|
| 5 | +import org.springframework.beans.factory.annotation.Value; |
|---|
| 3 | 6 | import org.springframework.boot.SpringApplication; |
|---|
| 4 | 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; |
|---|
| 5 | 8 | import org.springframework.boot.builder.SpringApplicationBuilder; |
|---|
| 9 | +import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; |
|---|
| 6 | 10 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; |
|---|
| 11 | +import org.springframework.context.annotation.Bean; |
|---|
| 7 | 12 | import org.springframework.context.annotation.ComponentScan; |
|---|
| 13 | +import org.springframework.context.annotation.Configuration; |
|---|
| 8 | 14 | |
|---|
| 9 | 15 | @ComponentScan(basePackages="it.digione.dg1cloud") |
|---|
| 16 | +@Configuration |
|---|
| 10 | 17 | @SpringBootApplication |
|---|
| 11 | 18 | public class Dg1cloudCoreApplication extends SpringBootServletInitializer { |
|---|
| 12 | 19 | |
|---|
| 20 | + @Value("${tomcat.MaxSwallowSize}") |
|---|
| 21 | + private int maxFileSize; |
|---|
| 22 | + |
|---|
| 13 | 23 | public static void main(String[] args) { |
|---|
| 14 | 24 | SpringApplication.run(Dg1cloudCoreApplication.class, args); |
|---|
| 15 | 25 | } |
|---|
| .. | .. |
|---|
| 18 | 28 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { |
|---|
| 19 | 29 | return application.sources(Dg1cloudCoreApplication.class); |
|---|
| 20 | 30 | } |
|---|
| 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 | + } |
|---|
| 21 | 47 | } |
|---|