org.apache.coyote.http11.AbstractHttp11Protocol Java Examples
The following examples show how to use
org.apache.coyote.http11.AbstractHttp11Protocol.
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: TomcatWebServer.java From oxygen with Apache License 2.0 | 6 votes |
private void configConnector(Connector connector, TomcatConf tomcatConf) { connector.setURIEncoding(tomcatConf.getUriEncoding()); ProtocolHandler protocolHandler = connector.getProtocolHandler(); if (protocolHandler instanceof AbstractProtocol) { AbstractProtocol<?> handler = (AbstractProtocol<?>) protocolHandler; handler.setAcceptCount(tomcatConf.getAcceptCount()); handler.setMaxConnections(tomcatConf.getMaxConnections()); handler.setMinSpareThreads(tomcatConf.getMinSpareThreads()); handler.setMaxThreads(tomcatConf.getMaxThreads()); handler.setConnectionTimeout(tomcatConf.getConnectionTimeout()); if (handler instanceof AbstractHttp11Protocol) { AbstractHttp11Protocol<?> protocol = (AbstractHttp11Protocol<?>) handler; protocol.setMaxHttpHeaderSize(tomcatConf.getMaxHttpHeaderSize()); } } }
Example #2
Source File: WebServerSecurityConfig.java From api-layer with Eclipse Public License 2.0 | 6 votes |
@Bean public WebServerFactoryCustomizer<TomcatServletWebServerFactory> servletContainerCustomizer() { return factory -> factory.addConnectorCustomizers(connector -> { AbstractHttp11Protocol abstractProtocol = (AbstractHttp11Protocol<?>) connector.getProtocolHandler(); abstractProtocol.setUseServerCipherSuitesOrder(true); }); }
Example #3
Source File: CrnkTomcatAutoConfiguration.java From crnk-framework with Apache License 2.0 | 6 votes |
@Override public void customize(Connector connector) { ProtocolHandler protocolHandler = connector.getProtocolHandler(); if (protocolHandler instanceof AbstractHttp11Protocol) { AbstractHttp11Protocol protocol11 = (AbstractHttp11Protocol) protocolHandler; try { String relaxedQueryChars = (String) PropertyUtils.getProperty(protocol11, PROPERTY_NAME); if (relaxedQueryChars == null) { relaxedQueryChars = ""; } relaxedQueryChars += "[]{}"; PropertyUtils.setProperty(protocol11, PROPERTY_NAME, relaxedQueryChars); } catch (Exception e) { LOGGER.debug("failed to set relaxed query charts, Tomcat might be outdated"); } } }
Example #4
Source File: LetsEncryptSetup.java From openwebbeans-meecrowave with Apache License 2.0 | 6 votes |
@Override public void accept(final Tomcat tomcat) { final ProtocolHandler protocolHandler = tomcat.getConnector().getProtocolHandler(); if (!AbstractHttp11Protocol.class.isInstance(protocolHandler)) { return; } final LetsEncryptReloadLifecycle.LetsEncryptConfig config = instance.getConfiguration() .getExtension(LetsEncryptReloadLifecycle.LetsEncryptConfig.class); if (config.getDomains() == null || config.getDomains().trim().isEmpty()) { return; } new LogFacade(getClass().getName()).info("Let's Encrypt extension activated"); tomcat.getHost().getPipeline().addValve(new LetsEncryptValve(AbstractHttp11Protocol.class.cast(protocolHandler), config)); }
Example #5
Source File: ServletContainerConfig.java From portal-de-servicos with MIT License | 6 votes |
@Bean public EmbeddedServletContainerCustomizer servletContainerCustomizer() { return servletContainer -> { addMimeMappingsForFonts(servletContainer); TomcatEmbeddedServletContainerFactory container = (TomcatEmbeddedServletContainerFactory) servletContainer; container.setRegisterJspServlet(false); container.addContextCustomizers(customizer -> customizer.addWelcomeFile("index.html")); container.addConnectorCustomizers( connector -> { AbstractHttp11Protocol httpProtocol = (AbstractHttp11Protocol) connector.getProtocolHandler(); httpProtocol.setCompression("on"); httpProtocol.setCompressionMinSize(256); httpProtocol.setCompressableMimeTypes(COMPRESSIBLE_MEDIA_TYPES); } ); }; }
Example #6
Source File: ManagerServlet.java From Tomcat8-Source-Read with MIT License | 5 votes |
protected void sslReload(PrintWriter writer, String tlsHostName, StringManager smClient) { Connector connectors[] = getConnectors(); boolean found = false; for (Connector connector : connectors) { if (Boolean.TRUE.equals(connector.getProperty("SSLEnabled"))) { ProtocolHandler protocol = connector.getProtocolHandler(); if (protocol instanceof AbstractHttp11Protocol<?>) { AbstractHttp11Protocol<?> http11Protoocol = (AbstractHttp11Protocol<?>) protocol; if (tlsHostName == null || tlsHostName.length() == 0) { found = true; http11Protoocol.reloadSslHostConfigs(); } else { SSLHostConfig[] sslHostConfigs = http11Protoocol.findSslHostConfigs(); for (SSLHostConfig sslHostConfig : sslHostConfigs) { if (sslHostConfig.getHostName().equalsIgnoreCase(tlsHostName)) { found = true; http11Protoocol.reloadSslHostConfig(tlsHostName); } } } } } } if (found) { if (tlsHostName == null || tlsHostName.length() == 0) { writer.println(smClient.getString("managerServlet.sslReloadAll")); } else { writer.println(smClient.getString("managerServlet.sslReload", tlsHostName)); } } else { writer.println(smClient.getString("managerServlet.sslReloadFail")); } }
Example #7
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 #8
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 #9
Source File: WebConfig.java From yfs with Apache License 2.0 | 5 votes |
@Bean public TomcatEmbeddedServletContainerFactory tomcatEmbedded() { TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory(); tomcat.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> { // configure maxSwallowSize if ((connector.getProtocolHandler() instanceof AbstractHttp11Protocol<?>)) { // -1 means unlimited, accept bytes ((AbstractHttp11Protocol<?>) connector.getProtocolHandler()).setMaxSwallowSize(-1); } }); return tomcat; }
Example #10
Source File: WebRestApiApplication.java From metasfresh-webui-api-legacy with GNU General Public License v3.0 | 5 votes |
@Bean public EmbeddedServletContainerCustomizer servletContainerCustomizer() { return servletContainer -> { final TomcatEmbeddedServletContainerFactory tomcatContainerFactory = (TomcatEmbeddedServletContainerFactory)servletContainer; tomcatContainerFactory.addConnectorCustomizers(connector -> { final AbstractHttp11Protocol<?> httpProtocol = (AbstractHttp11Protocol<?>)connector.getProtocolHandler(); httpProtocol.setCompression("on"); httpProtocol.setCompressionMinSize(256); final String mimeTypes = httpProtocol.getCompressibleMimeType(); final String mimeTypesWithJson = mimeTypes + "," + MediaType.APPLICATION_JSON_VALUE + ",application/javascript"; httpProtocol.setCompressibleMimeType(mimeTypesWithJson); }); }; }
Example #11
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 #12
Source File: ConnectorConfigTest.java From tomee with Apache License 2.0 | 5 votes |
@Test public void createConnector() { final AtomicReference<Connector> connector = new AtomicReference<>(); try { new Container(new Configuration() .property("connector.xpoweredBy", "true") .property("connector.attributes.compression", "on") .property("connector.attributes.maxHeaderCount", "2016")) { @Override protected Connector createConnector() { final Connector connector1 = super.createConnector(); connector.set(connector1); throw new RuntimeException("end"); } }; fail("we throw an exception to prevent startup"); } catch (final Exception re) { assertEquals(re.getMessage(), "java.lang.RuntimeException: end", re.getMessage()); final Connector c = connector.get(); assertNotNull(c); assertTrue(c.getXpoweredBy()); assertEquals(2016, AbstractHttp11Protocol.class.cast(c.getProtocolHandler()).getMaxHeaderCount()); assertEquals("on", AbstractHttp11Protocol.class.cast(c.getProtocolHandler()).getCompression()); } }
Example #13
Source File: LetsEncryptValve.java From openwebbeans-meecrowave with Apache License 2.0 | 4 votes |
public LetsEncryptValve(final AbstractHttp11Protocol<?> protocol, final LetsEncryptReloadLifecycle.LetsEncryptConfig config) { super(true); this.protocol = protocol; this.config = config; }
Example #14
Source File: CredHubApp.java From credhub with Apache License 2.0 | 4 votes |
@Bean public WebServerFactoryCustomizer servletContainerCustomizer() { return (factory) -> ((TomcatServletWebServerFactory) factory) .addConnectorCustomizers((connector) -> ((AbstractHttp11Protocol<?>) connector.getProtocolHandler()) .setUseServerCipherSuitesOrder(true)); }
Example #15
Source File: TomcatServer.java From onetwo with Apache License 2.0 | 4 votes |
public void initialize() { try { JFishTomcat tomcat = new JFishTomcat(); if(serverConfig.getTomcatContextClassName()!=null){ tomcat.setContextClass((Class<StandardContext>)ReflectUtils.loadClass(serverConfig.getTomcatContextClassName(), true)); } int port = serverConfig.getPort(); tomcat.setPort(port); // tomcat.setBaseDir(webConfig.getServerBaseDir()); String baseDir = null; if(!Utils.isBlank(serverConfig.getServerBaseDir())){ baseDir = serverConfig.getServerBaseDir(); }else{ baseDir = System.getProperty("java.io.tmpdir"); logger.info("set serverBaseDir as java.io.tmpdir : {} ", baseDir); } tomcat.setBaseDir(baseDir); // This magic line makes Tomcat look for WAR files in catalinaHome/webapps // and automatically deploy them // tomcat.getHost().addLifecycleListener(new HostConfig()); appBaseFile = new File(baseDir+"/tomcat.webapps."+this.serverConfig.getPort()); if(!appBaseFile.exists()){ appBaseFile.mkdirs(); } appBaseFile.deleteOnExit(); tomcat.getHost().setAppBase(appBaseFile.getAbsolutePath()); Connector connector = tomcat.getConnector(); connector.setURIEncoding("UTF-8"); connector.setRedirectPort(serverConfig.getRedirectPort()); connector.setMaxPostSize(serverConfig.getMaxPostSize()); ProtocolHandler protocol = connector.getProtocolHandler(); if(protocol instanceof AbstractHttp11Protocol){ /***** * <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8181" compression="500" compressableMimeType="text/html,text/xml,text/plain,application/octet-stream" /> */ AbstractHttp11Protocol<?> hp = (AbstractHttp11Protocol<?>) protocol; hp.setCompression("on"); hp.setCompressableMimeTypes("text/html,text/xml,text/plain,application/octet-stream"); } StandardServer server = (StandardServer) tomcat.getServer(); AprLifecycleListener listener = new AprLifecycleListener(); server.addLifecycleListener(listener); /*tomcat.addUser("adminuser", "adminuser"); tomcat.addRole("adminuser", "admin"); tomcat.addRole("adminuser", "admin");*/ this.tomcat = tomcat; } catch (Exception e) { throw new RuntimeException("web server initialize error , check it. " + e.getMessage(), e); } /*Runtime.getRuntime().addShutdownHook(new Thread(){ @Override public void run() { appBaseFile.delete(); } });*/ }