Java Code Examples for org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory#addConnectorCustomizers()
The following examples show how to use
org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory#addConnectorCustomizers() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BrokerApplication.java From WeEvent with Apache License 2.0 | 6 votes |
@Bean public ConfigurableServletWebServerFactory configurableServletWebServerFactory() { log.info("custom TomcatServletWebServerFactory"); TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); factory.setProtocol(TomcatServletWebServerFactory.DEFAULT_PROTOCOL); factory.addConnectorCustomizers((connector) -> { // default max connections = 10000 // default connection timeout = 20000 // default max accept count = 100 // default max worker thread = 200 connector.setEnableLookups(false); connector.setAllowTrace(false); Http11NioProtocol http11NioProtocol = (Http11NioProtocol) connector.getProtocolHandler(); http11NioProtocol.setKeepAliveTimeout(60000); http11NioProtocol.setMaxKeepAliveRequests(10000); http11NioProtocol.setDisableUploadTimeout(true); http11NioProtocol.setTcpNoDelay(true); } ); return factory; }
Example 2
Source File: ChengfengConfig.java From ChengFeng1.5 with MIT License | 5 votes |
@Bean public TomcatServletWebServerFactory tomcatEmbedded() { TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); tomcat.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> { if ((connector.getProtocolHandler() instanceof AbstractHttp11Protocol<?>)) { //-1 means unlimited ((AbstractHttp11Protocol<?>) connector.getProtocolHandler()).setMaxSwallowSize(-1); } }); return tomcat; }
Example 3
Source File: WebServerConfig.java From NettyReverseProxy with Apache License 2.0 | 5 votes |
/** * tomcat配置 */ @Bean public TomcatServletWebServerFactory servletContainer() { TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); factory.getSession().setTimeout(Duration.ofMinutes(10)); factory.addConnectorCustomizers(new TomcatConnectorCustomizer() { @Override public void customize(Connector connector) { AbstractHttp11Protocol httpProtocol = (AbstractHttp11Protocol) connector.getProtocolHandler(); httpProtocol.setCompression("on"); httpProtocol.setCompressibleMimeType("text/html,text/xml,text/plain,application/json,application/xml"); } }); return factory; }
Example 4
Source File: TomcatConfig.java From OneBlog with GNU General Public License v3.0 | 5 votes |
@Bean public ConfigurableServletWebServerFactory webServerFactory() { TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); factory.addConnectorCustomizers( connector -> { Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler(); protocol.setDisableUploadTimeout(false); } ); return factory; }
Example 5
Source File: FileUploadApplication.java From parker with MIT License | 5 votes |
@Bean public TomcatServletWebServerFactory tomcatEmbedded() { TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); tomcat.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> { if ((connector.getProtocolHandler() instanceof AbstractHttp11Protocol<?>)) { //-1 means unlimited ((AbstractHttp11Protocol<?>) connector.getProtocolHandler()).setMaxSwallowSize(-1); } }); return tomcat; }
Example 6
Source File: TomcatConfig.java From singleton with Eclipse Public License 2.0 | 5 votes |
@Bean public ServletWebServerFactory servletContainer(ServerProperties serverProperties) { TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); tomcat.addConnectorCustomizers(new VIPTomcatConnectionCustomizer(serverProperties)); if (serverProperties.getServerScheme().equalsIgnoreCase(ConstantsTomcat.HTTP_HTTPS) || serverProperties.getServerScheme().equalsIgnoreCase(ConstantsTomcat.HTTPS_HTTP)) { tomcat.addAdditionalTomcatConnectors(initiateHttpsConnector(serverProperties)); } return tomcat; }
Example 7
Source File: TomcatConfig.java From singleton with Eclipse Public License 2.0 | 5 votes |
@Bean public ServletWebServerFactory servletContainer(ServerProperties serverProperties) { TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); tomcat.addConnectorCustomizers(new VIPTomcatConnectionCustomizer(serverProperties)); if (serverProperties.getServerScheme().equalsIgnoreCase(ConstantsTomcat.HTTP_HTTPS) || serverProperties.getServerScheme().equalsIgnoreCase(ConstantsTomcat.HTTPS_HTTP)) { tomcat.addAdditionalTomcatConnectors(initiateHttpsConnector(serverProperties)); } return tomcat; }
Example 8
Source File: WebConfig.java From flash-waimai with MIT License | 5 votes |
@Bean public ConfigurableServletWebServerFactory webServerFactory() { TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); factory.addConnectorCustomizers(new TomcatConnectorCustomizer() { @Override public void customize(Connector connector) { connector.setProperty("relaxedQueryChars", "|{}[]"); } }); return factory; }
Example 9
Source File: TomcatConfiguration.java From cymbal with Apache License 2.0 | 5 votes |
@Bean public ConfigurableServletWebServerFactory webServerFactory() { TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); factory.addConnectorCustomizers( (TomcatConnectorCustomizer) connector -> connector.setProperty("relaxedQueryChars", "|{}[]\\")); return factory; }
Example 10
Source File: WebasebeeApplication.java From WeBASE-Collect-Bee with Apache License 2.0 | 5 votes |
/** * 配置tomcat * * @return */ @Bean public ServletWebServerFactory servletContainer() { TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); tomcat.addConnectorCustomizers(gracefulShutdown()); return tomcat; }
Example 11
Source File: PortalTomcatWebServerCustomizer.java From seppb with MIT License | 5 votes |
@Override public void customize(WebServerFactory container) { TomcatServletWebServerFactory containerFactory = (TomcatServletWebServerFactory) container; containerFactory.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> { connector.setAttribute("relaxedQueryChars", "[]|{}^\" < > "); connector.setAttribute("relaxedPathChars", "[]|"); }); }
Example 12
Source File: AppRun.java From yshopmall with Apache License 2.0 | 4 votes |
@Bean public ServletWebServerFactory webServerFactory() { TomcatServletWebServerFactory fa = new TomcatServletWebServerFactory(); fa.addConnectorCustomizers(connector -> connector.setProperty("relaxedQueryChars", "[]{}")); return fa; }
Example 13
Source File: GracefulShutdownTomcatContainerCustomizer.java From spring-boot-graceful-shutdown with Apache License 2.0 | 4 votes |
@Override public void customize(TomcatServletWebServerFactory factory) { factory.addConnectorCustomizers(connectorCustomizer); }
Example 14
Source File: AppRun.java From eladmin with Apache License 2.0 | 4 votes |
@Bean public ServletWebServerFactory webServerFactory() { TomcatServletWebServerFactory fa = new TomcatServletWebServerFactory(); fa.addConnectorCustomizers(connector -> connector.setProperty("relaxedQueryChars", "[]{}")); return fa; }
Example 15
Source File: TestConfig.java From staffjoy with MIT License | 4 votes |
@Bean public ServletWebServerFactory servletContainer() { TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); tomcat.addConnectorCustomizers(connector -> connector.setAllowTrace(true)); return tomcat; }
Example 16
Source File: HttpServer.java From guardedbox with GNU Affero General Public License v3.0 | 4 votes |
/** * Bean: ServletWebServerFactory. * Creates a dual port Tomcat, listening both in an http port and an https port. The http port simply redirects to the https one. * * @return TomcatServletWebServerFactory. */ @Bean public ServletWebServerFactory servletWebServerFactory() { // Check if there is dual port configuration. if (serverProperties.getInternalHttpPort() == null || serverProperties.getExternalHttpPort() == null || serverProperties.getInternalHttpsPort() == null || serverProperties.getExternalHttpsPort() == null || serverProperties.getPort().equals(serverProperties.getInternalHttpPort()) || !serverProperties.getPort().equals(serverProperties.getInternalHttpsPort())) { return new TomcatServletWebServerFactory(); } // Set TLS ECDH offered curves. if (!StringUtils.isEmpty(sslProperties.getEcdhCurves())) System.setProperty(JdkProperty.TLS_ECDH_CURVES.getPropertyName(), sslProperties.getEcdhCurves()); // Enable TLS OCSP stapling. if (sslProperties.getEnableOcspStapling() != null) System.setProperty(JdkProperty.TLS_ENABLE_OCSP_STAPLING.getPropertyName(), sslProperties.getEnableOcspStapling().toString()); // Create the https Tomcat. TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory() { @Override protected void postProcessContext( Context context) { SecurityConstraint securityConstraint = new SecurityConstraint(); securityConstraint.setUserConstraint("CONFIDENTIAL"); SecurityCollection collection = new SecurityCollection(); collection.addPattern("/*"); securityConstraint.addCollection(collection); context.addConstraint(securityConstraint); } }; // Customize the https connector. tomcat.addConnectorCustomizers(new TomcatConnectorCustomizer() { @Override public void customize( Connector connector) { SSLHostConfig sslHostConfig = connector.findSslHostConfigs()[0]; sslHostConfig.setHonorCipherOrder(true); } }); // Add the http connector with a redirection to the https port. Connector httpConnector = new Connector(TomcatServletWebServerFactory.DEFAULT_PROTOCOL); httpConnector.setScheme("http"); httpConnector.setPort(serverProperties.getInternalHttpPort()); httpConnector.setSecure(false); httpConnector.setRedirectPort(serverProperties.getExternalHttpsPort()); tomcat.addAdditionalTomcatConnectors(httpConnector); return tomcat; }
Example 17
Source File: CustomTomcat.java From mdw with Apache License 2.0 | 4 votes |
@Override public void customize(TomcatServletWebServerFactory factory) { connectorCustomizer = new MdwServletContainerFactory.ConnectorCustomizer(); factory.addConnectorCustomizers(connectorCustomizer); }
Example 18
Source File: SkApplication.java From sk-admin with Apache License 2.0 | 4 votes |
@Bean public ServletWebServerFactory webServerFactory() { TomcatServletWebServerFactory fa = new TomcatServletWebServerFactory(); fa.addConnectorCustomizers(connector -> connector.setProperty("relaxedQueryChars", "[]{}")); return fa; }
Example 19
Source File: App.java From modeldb with Apache License 2.0 | 4 votes |
@Bean public ServletWebServerFactory servletContainer(final GracefulShutdown gracefulShutdown) { TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); factory.addConnectorCustomizers(gracefulShutdown); return factory; }