You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ja...@apache.org on 2019/02/28 15:12:20 UTC
svn commit: r1854532 - in /ofbiz/ofbiz-framework/trunk/framework/catalina:
ofbiz-component.xml
src/main/java/org/apache/ofbiz/catalina/container/CatalinaContainer.java
Author: jacopoc
Date: Thu Feb 28 15:12:20 2019
New Revision: 1854532
URL: http://svn.apache.org/viewvc?rev=1854532&view=rev
Log:
Implemented: Added ability to configure the embedded Tomcat instance to
communicate using the HTTP/2 protocol, when the client supports it.
With this commit HTTP/2 is enabled by default, by setting upgradeProtocol=true
in the http and https connectors of Tomcat; however the connectors will continue
to support HTTP/1.1 (the switch to HTTP/2 is negotiated with the client using
the "HTTP Upgrade Protocol"); if the new "upgradeProtocol" property, introduced
in this commit for this specific purpose, is not set (as it would be the case in
custom configuration files) then the new protocol will not be enabled.
Additional Tomcat specific configuration options are available (see
https://tomcat.apache.org/tomcat-9.0-doc/config/http2.html) but this commit
doesn't implement the ability to set them (this is left to a future enhancement,
if there will be a requirement to change the default values).
Modified:
ofbiz/ofbiz-framework/trunk/framework/catalina/ofbiz-component.xml
ofbiz/ofbiz-framework/trunk/framework/catalina/src/main/java/org/apache/ofbiz/catalina/container/CatalinaContainer.java
Modified: ofbiz/ofbiz-framework/trunk/framework/catalina/ofbiz-component.xml
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/catalina/ofbiz-component.xml?rev=1854532&r1=1854531&r2=1854532&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/catalina/ofbiz-component.xml (original)
+++ ofbiz/ofbiz-framework/trunk/framework/catalina/ofbiz-component.xml Thu Feb 28 15:12:20 2019
@@ -99,6 +99,7 @@ under the License.
<!--<property name="address" value=""/>-->
<property name="port" value="8080"/>
<property name="protocol" value="HTTP/1.1"/>
+ <property name="upgradeProtocol" value="true"/>
<property name="scheme" value="http"/>
<property name="secure" value="false"/>
<property name="URIEncoding" value="UTF-8"/>
@@ -128,6 +129,7 @@ under the License.
<!--<property name="address" value=""/>-->
<property name="port" value="8443"/>
<property name="protocol" value="HTTP/1.1"/>
+ <property name="upgradeProtocol" value="true"/>
<property name="scheme" value="https"/>
<property name="secure" value="true"/>
<property name="SSLEnabled" value="true"/>
@@ -183,6 +185,7 @@ under the License.
<!--<property name="address" value=""/>-->
<property name="port" value="8080"/>
<property name="protocol" value="HTTP/1.1"/>
+ <property name="upgradeProtocol" value="true"/>
<property name="scheme" value="http"/>
<property name="secure" value="false"/>
<property name="URIEncoding" value="UTF-8"/>
@@ -194,6 +197,7 @@ under the License.
<!--<property name="address" value=""/>-->
<property name="port" value="8443"/>
<property name="protocol" value="HTTP/1.1"/>
+ <property name="upgradeProtocol" value="true"/>
<property name="scheme" value="https"/>
<property name="secure" value="true"/>
<property name="SSLEnabled" value="true"/>
Modified: ofbiz/ofbiz-framework/trunk/framework/catalina/src/main/java/org/apache/ofbiz/catalina/container/CatalinaContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/catalina/src/main/java/org/apache/ofbiz/catalina/container/CatalinaContainer.java?rev=1854532&r1=1854531&r2=1854532&view=diff
==============================================================================
--- ofbiz/ofbiz-framework/trunk/framework/catalina/src/main/java/org/apache/ofbiz/catalina/container/CatalinaContainer.java (original)
+++ ofbiz/ofbiz-framework/trunk/framework/catalina/src/main/java/org/apache/ofbiz/catalina/container/CatalinaContainer.java Thu Feb 28 15:12:20 2019
@@ -63,6 +63,7 @@ import org.apache.catalina.tribes.transp
import org.apache.catalina.util.ServerInfo;
import org.apache.catalina.valves.AccessLogValve;
import org.apache.catalina.webresources.StandardRoot;
+import org.apache.coyote.http2.Http2Protocol;
import org.apache.ofbiz.base.component.ComponentConfig;
import org.apache.ofbiz.base.concurrent.ExecutionPool;
import org.apache.ofbiz.base.container.Container;
@@ -417,9 +418,12 @@ public class CatalinaContainer implement
private Connector prepareConnector(Property connectorProp) {
Connector connector = new Connector(ContainerConfig.getPropertyValue(connectorProp, "protocol", "HTTP/1.1"));
connector.setPort(ContainerConfig.getPropertyValue(connectorProp, "port", 0) + Start.getInstance().getConfig().portOffset);
-
+ if ("true".equals(ContainerConfig.getPropertyValue(connectorProp, "upgradeProtocol", "false"))) {
+ connector.addUpgradeProtocol(new Http2Protocol());
+ Debug.logInfo("Tomcat " + connector + ": enabled HTTP/2", module);
+ }
connectorProp.properties.values().stream()
- .filter(prop -> !"protocol".equals(prop.name) && !"port".equals(prop.name))
+ .filter(prop -> !"protocol".equals(prop.name) && !"upgradeProtocol".equals(prop.name) && !"port".equals(prop.name))
.forEach(prop -> {
if (IntrospectionUtils.setProperty(connector, prop.name, prop.value)) {
if (prop.name.indexOf("Pass") != -1) {