diff --git a/jplugin-embed-tomcat/src/main/java/net/jplugin/extension/embed_tomcat/impl/EmbedTomcatConfig.java b/jplugin-embed-tomcat/src/main/java/net/jplugin/extension/embed_tomcat/impl/EmbedTomcatConfig.java index 9e4f0b5..4bb9ace 100644 --- a/jplugin-embed-tomcat/src/main/java/net/jplugin/extension/embed_tomcat/impl/EmbedTomcatConfig.java +++ b/jplugin-embed-tomcat/src/main/java/net/jplugin/extension/embed_tomcat/impl/EmbedTomcatConfig.java @@ -15,22 +15,22 @@ public class EmbedTomcatConfig { private static final String CONTEXT_NAME = "embed-tomcat.context-name"; - private static final String PROTOCOL_COMPRESSABLE_MIME_TYPE = "embed-tomcat.protocol.compressable-mime-type"; + private static final String PROTOCOL_COMPRESSABLE_MIME_TYPE = "embed-tomcat.protocol-compressable-mime-type"; - private static final String PROTOCOL_MAX_THREADS = "embed-tomcat.protocol.max-threads"; + private static final String PROTOCOL_MAX_THREADS = "embed-tomcat.protocol-max-threads"; - private static final String PROTOCOL_MAX_CONNECTIONS = "embed-tomcat.protocol.max-connections"; + private static final String PROTOCOL_MAX_CONNECTIONS = "embed-tomcat.protocol-max-connections"; - private static final String PROTOCOL_CONNECTION_TIMEOUT = "embed-tomcat.protocol.connection-timeout"; + private static final String PROTOCOL_CONNECTION_TIMEOUT = "embed-tomcat.protocol-connection-timeout"; - private static final String PROTOCOL_MIN_SPARE_THREADS = "embed-tomcat.protocol.min-spare-threads"; + private static final String PROTOCOL_MIN_SPARE_THREADS = "embed-tomcat.protocol-min-spare-threads"; - private static final String PROTOCOL_KEEPALIVE_TIMEOUT = "embed-tomcat.protocol.keepalive-timeout"; + private static final String PROTOCOL_KEEPALIVE_TIMEOUT = "embed-tomcat.protocol-keepalive-timeout"; - private static final String PROTOCOL_ACCEPTOR_THREADCOUNT = "embed-tomcat.protocol.acceptor-threadCount"; + private static final String PROTOCOL_ACCEPTOR_THREADCOUNT = "embed-tomcat.protocol-acceptor-threadCount"; private static final String REDIRECT_PORT = "embed-tomcat.redirect-port"; @@ -38,6 +38,9 @@ public class EmbedTomcatConfig { private static final String MAX_POST_SIZE = "embed-tomcat.max-post-size"; + private static final String USE_BODY_ENCODING_FOR_URI = "embed-tomcat.use-body-encoding-for-uri"; + + private static final String PROTOCOL_COMPRESSION = "embed-tomcat.protocol.compression"; @@ -56,6 +59,7 @@ public class EmbedTomcatConfig { private static String compressableMimeType; private static Integer maxPostSize; private static String compression; + private static Boolean useBodyEncodingForURI; public static void init() { tomcatPort = ConfigFactory.getIntConfig(TOMCAT_PORT, 8080); @@ -80,15 +84,21 @@ public static void init() { maxPostSize = ConfigFactory.getIntConfig(MAX_POST_SIZE); - compression= ConfigFactory.getStringConfigWithTrim(PROTOCOL_COMPRESSION); + compression = ConfigFactory.getStringConfigWithTrim(PROTOCOL_COMPRESSION); + useBodyEncodingForURI = "true".equalsIgnoreCase(ConfigFactory.getStringConfigWithTrim(USE_BODY_ENCODING_FOR_URI)); StringBuffer sb = new StringBuffer(); sb.append("$$$ Embed Tomcat config:\n tomcatPort=" + tomcatPort) .append("\n useWebSupport:" + useWebSupport) .append("\n contextName:" + contextName) - .append("\n maxThreads:" + maxThreads) - .append("\n maxConnections:" + maxConnections) - .append("\n connectionTimeout:" + connectionTimeout); + .append("\n maxThreads:" + maxThreads) + .append("\n maxConnections:" + maxConnections) + .append("\n compressableMimeType:" + compressableMimeType) + .append("\n redirectPort:" + redirectPort) + .append("\n connectionTimeout:" + connectionTimeout) + .append("\n maxPostSize:" + maxPostSize) + .append("\n compression:" + compression) + .append("\n useBodyEncodingForURI:" + useBodyEncodingForURI); PluginEnvirement.getInstance().getStartLogger().log(sb.toString()); @@ -145,11 +155,15 @@ public static String getUriEncoding() { return uriEncoding; } - public static Integer getMaxPostSize() { - return maxPostSize; - } + public static Integer getMaxPostSize() { + return maxPostSize; + } public static String getCompression() { return compression; } + + public static Boolean getUseBodyEncodingForURI() { + return useBodyEncodingForURI; + } } diff --git a/jplugin-embed-tomcat/src/main/java/net/jplugin/extension/embed_tomcat/impl/TomcatStarter.java b/jplugin-embed-tomcat/src/main/java/net/jplugin/extension/embed_tomcat/impl/TomcatStarter.java index 66743fc..188e5e0 100644 --- a/jplugin-embed-tomcat/src/main/java/net/jplugin/extension/embed_tomcat/impl/TomcatStarter.java +++ b/jplugin-embed-tomcat/src/main/java/net/jplugin/extension/embed_tomcat/impl/TomcatStarter.java @@ -53,18 +53,18 @@ public static Tomcat start() throws Exception { /** * + * maxPostSize="209715200" ok + * compressableMimeType="text/html,text/xml,text/plain,text/javascript,text/css,application/octet-stream" /> on * * @param connector */ @@ -76,11 +76,14 @@ private static void customConnector(Connector connector) { if (EmbedTomcatConfig.getRedirectPort() != null) { connector.setRedirectPort(EmbedTomcatConfig.getRedirectPort()); } - if (EmbedTomcatConfig.getUriEncoding() != null && !"".equals(EmbedTomcatConfig.getUriEncoding())) { connector.setURIEncoding(EmbedTomcatConfig.getUriEncoding()); } + if(EmbedTomcatConfig.getUseBodyEncodingForURI()!=null){ + connector.setUseBodyEncodingForURI(EmbedTomcatConfig.getUseBodyEncodingForURI()); + } + // 设置最大线程数 if (EmbedTomcatConfig.getMaxThreads() != null) { @@ -122,8 +125,10 @@ private static void customConnector(Connector connector) { if (EmbedTomcatConfig.getCompression() != null && !"".equals(EmbedTomcatConfig.getCompression())) { protocol.setCompression(EmbedTomcatConfig.getCompression()); } + //protocol.setNoCompressionUserAgents("gozilla, traviata"); + } /** diff --git a/jplugin-embed-tomcat/src/main/resources/config/embed-tomcat.config.properties b/jplugin-embed-tomcat/src/main/resources/config/embed-tomcat.config.properties index 2f768a9..2fec8c2 100644 --- a/jplugin-embed-tomcat/src/main/resources/config/embed-tomcat.config.properties +++ b/jplugin-embed-tomcat/src/main/resources/config/embed-tomcat.config.properties @@ -4,6 +4,7 @@ protocol.max-threads=1000 #redirect-port= #uri-encoding= #max-post-size= +#use-body-encoding-for-uri= #protocol.max-threads= #protocol.max-connections= #protocol.connection-timeout= @@ -11,3 +12,4 @@ protocol.max-threads=1000 #protocol.keepalive-timeout= #protocol.acceptor-threadCount= #protocol.compression= +