@ -17,6 +17,8 @@
package org.springframework.boot.autoconfigure.web.embedded ;
import java.time.Duration ;
import java.util.List ;
import java.util.stream.Collectors ;
import org.apache.catalina.Lifecycle ;
import org.apache.catalina.valves.AccessLogValve ;
@ -51,6 +53,7 @@ import org.springframework.util.unit.DataSize;
* @author Artsiom Yudovin
* @author Chentao Qu
* @author Andrew McGhie
* @author Dirk Deyne
* @since 2.0 .0
* /
public class TomcatWebServerFactoryCustomizer
@ -102,6 +105,10 @@ public class TomcatWebServerFactoryCustomizer
. to ( ( acceptCount ) - > customizeAcceptCount ( factory , acceptCount ) ) ;
propertyMapper . from ( tomcatProperties : : getProcessorCache )
. to ( ( processorCache ) - > customizeProcessorCache ( factory , processorCache ) ) ;
propertyMapper . from ( tomcatProperties : : getRelaxedPathChars ) . as ( this : : joinCharacters ) . whenHasText ( )
. to ( ( relaxedChars ) - > customizeRelaxedPathChars ( factory , relaxedChars ) ) ;
propertyMapper . from ( tomcatProperties : : getRelaxedQueryChars ) . as ( this : : joinCharacters ) . whenHasText ( )
. to ( ( relaxedChars ) - > customizeRelaxedQueryChars ( factory , relaxedChars ) ) ;
customizeStaticResources ( factory ) ;
customizeErrorReportValve ( properties . getError ( ) , factory ) ;
}
@ -149,6 +156,18 @@ public class TomcatWebServerFactoryCustomizer
} ) ;
}
private void customizeRelaxedPathChars ( ConfigurableTomcatWebServerFactory factory , String relaxedChars ) {
factory . addConnectorCustomizers ( ( connector ) - > connector . setAttribute ( "relaxedPathChars" , relaxedChars ) ) ;
}
private void customizeRelaxedQueryChars ( ConfigurableTomcatWebServerFactory factory , String relaxedChars ) {
factory . addConnectorCustomizers ( ( connector ) - > connector . setAttribute ( "relaxedQueryChars" , relaxedChars ) ) ;
}
private String joinCharacters ( List < Character > content ) {
return content . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( ) ) ;
}
private void customizeRemoteIpValve ( ConfigurableTomcatWebServerFactory factory ) {
Tomcat tomcatProperties = this . serverProperties . getTomcat ( ) ;
String protocolHeader = tomcatProperties . getProtocolHeader ( ) ;