You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2020/04/07 18:57:14 UTC

[tomcat] branch master updated: Move getProtocol method to be consistent

This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new 1eabf4e  Move getProtocol method to be consistent
1eabf4e is described below

commit 1eabf4e3d2059cd684b1f075059ba1e31a69ecf3
Author: remm <re...@apache.org>
AuthorDate: Tue Apr 7 20:56:57 2020 +0200

    Move getProtocol method to be consistent
---
 java/org/apache/catalina/connector/Connector.java |  7 +------
 java/org/apache/coyote/ProtocolHandler.java       | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/catalina/connector/Connector.java b/java/org/apache/catalina/connector/Connector.java
index ca7b909..f529161 100644
--- a/java/org/apache/catalina/connector/Connector.java
+++ b/java/org/apache/catalina/connector/Connector.java
@@ -651,12 +651,7 @@ public class Connector extends LifecycleMBeanBase  {
      * @return the Coyote protocol handler in use.
      */
     public String getProtocol() {
-        if ("org.apache.coyote.http11.Http11NioProtocol".equals(getProtocolHandlerClassName())) {
-            return "HTTP/1.1";
-        } else if ("org.apache.coyote.ajp.AjpNioProtocol".equals(getProtocolHandlerClassName())) {
-            return "AJP/1.3";
-        }
-        return getProtocolHandlerClassName();
+        return ProtocolHandler.getProtocol(getProtocolHandlerClassName());
     }
 
 
diff --git a/java/org/apache/coyote/ProtocolHandler.java b/java/org/apache/coyote/ProtocolHandler.java
index c6e1565..902e86e 100644
--- a/java/org/apache/coyote/ProtocolHandler.java
+++ b/java/org/apache/coyote/ProtocolHandler.java
@@ -222,4 +222,18 @@ public interface ProtocolHandler {
     }
 
 
+    /**
+     * Get the protocol name associated with the protocol class.
+     * @param protocolClassName the protocol class name
+     * @return the protocol name
+     */
+    public static String getProtocol(String protocolClassName) {
+        if (org.apache.coyote.http11.Http11NioProtocol.class.getName().equals(protocolClassName)) {
+            return "HTTP/1.1";
+        } else if (org.apache.coyote.ajp.AjpNioProtocol.class.getName().equals(protocolClassName)) {
+            return "AJP/1.3";
+        }
+        return protocolClassName;
+    }
+
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org