You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2021/10/07 17:13:36 UTC
[tomcat] branch main updated (b505fdc -> cf43fa0)
This is an automated email from the ASF dual-hosted git repository.
markt pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git.
from b505fdc Add missing string
new 897f4f6 Add new, standard method for direct upgrade to WebSocket
new cf43fa0 Remove deprecated method
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
java/jakarta/websocket/server/ServerContainer.java | 34 ++++++++++++++++++++--
.../tomcat/websocket/server/WsServerContainer.java | 33 +++++++--------------
webapps/docs/changelog.xml | 5 ++++
3 files changed, 47 insertions(+), 25 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[tomcat] 02/02: Remove deprecated method
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit cf43fa01d03e5acc1bf3244bd6a2a6b060c86ef6
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Oct 7 18:11:14 2021 +0100
Remove deprecated method
---
.../tomcat/websocket/server/WsServerContainer.java | 31 ----------------------
1 file changed, 31 deletions(-)
diff --git a/java/org/apache/tomcat/websocket/server/WsServerContainer.java b/java/org/apache/tomcat/websocket/server/WsServerContainer.java
index b6949a6..135a1ba 100644
--- a/java/org/apache/tomcat/websocket/server/WsServerContainer.java
+++ b/java/org/apache/tomcat/websocket/server/WsServerContainer.java
@@ -296,37 +296,6 @@ public class WsServerContainer extends WsWebSocketContainer
}
- /**
- * Until the WebSocket specification provides such a mechanism, this Tomcat
- * proprietary method is provided to enable applications to programmatically
- * determine whether or not to upgrade an individual request to WebSocket.
- * <p>
- * Note: This method is not used by Tomcat but is used directly by
- * third-party code and must not be removed.
- *
- * @param request The request object to be upgraded
- * @param response The response object to be populated with the result of
- * the upgrade
- * @param sec The server endpoint to use to process the upgrade request
- * @param pathParams The path parameters associated with the upgrade request
- *
- * @throws ServletException If a configuration error prevents the upgrade
- * from taking place
- * @throws IOException If an I/O error occurs during the upgrade process
- *
- * @deprecated This method will be removed in Apache Tomcat 10.1 onwards. It
- * has been replaced by {@link #upgradeHttpToWebSocket(Object,
- * Object, ServerEndpointConfig, Map)}
- */
- @Deprecated
- public void doUpgrade(HttpServletRequest request,
- HttpServletResponse response, ServerEndpointConfig sec,
- Map<String,String> pathParams)
- throws ServletException, IOException {
- UpgradeUtil.doUpgrade(this, request, response, sec, pathParams);
- }
-
-
@Override
public void upgradeHttpToWebSocket(Object httpServletRequest, Object httpServletResponse,
ServerEndpointConfig sec, Map<String, String> pathParameters)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[tomcat] 01/02: Add new,
standard method for direct upgrade to WebSocket
Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 897f4f6f862904379662e215d3dc9d956fb5652f
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Oct 7 18:10:37 2021 +0100
Add new, standard method for direct upgrade to WebSocket
---
java/jakarta/websocket/server/ServerContainer.java | 34 ++++++++++++++++++++--
.../tomcat/websocket/server/WsServerContainer.java | 18 ++++++++++++
webapps/docs/changelog.xml | 5 ++++
3 files changed, 55 insertions(+), 2 deletions(-)
diff --git a/java/jakarta/websocket/server/ServerContainer.java b/java/jakarta/websocket/server/ServerContainer.java
index a210311..4820cb6 100644
--- a/java/jakarta/websocket/server/ServerContainer.java
+++ b/java/jakarta/websocket/server/ServerContainer.java
@@ -16,6 +16,9 @@
*/
package jakarta.websocket.server;
+import java.io.IOException;
+import java.util.Map;
+
import jakarta.websocket.DeploymentException;
import jakarta.websocket.WebSocketContainer;
@@ -25,6 +28,33 @@ import jakarta.websocket.WebSocketContainer;
public interface ServerContainer extends WebSocketContainer {
public abstract void addEndpoint(Class<?> clazz) throws DeploymentException;
- public abstract void addEndpoint(ServerEndpointConfig sec)
- throws DeploymentException;
+ public abstract void addEndpoint(ServerEndpointConfig sec) throws DeploymentException;
+
+ /**
+ * Upgrade the HTTP connection represented by the {@code HttpServletRequest} and {@code HttpServletResponse} to the
+ * WebSocket protocol and establish a WebSocket connection as per the provided {@link ServerEndpointConfig}.
+ * <p>
+ * This method is primarily intended to be used by frameworks that implement the front-controller pattern. It does
+ * not deploy the provided endpoint.
+ * <p>
+ * If the WebSocket implementation is not deployed as part of a Jakarta Servlet container, this method will throw an
+ * {@link UnsupportedOperationException}.
+ *
+ * @param httpServletRequest The {@code HttpServletRequest} to be processed as a WebSocket handshake as per
+ * section 4.0 of RFC 6455.
+ * @param httpServletResponse The {@code HttpServletResponse} to be used when processing the
+ * {@code httpServletRequest} as a WebSocket handshake as per section 4.0 of RFC 6455.
+ * @param sec The server endpoint configuration to use to configure the WebSocket endpoint
+ * @param pathParameters Provides a mapping of path parameter names and values, if any, to be used for the
+ * WebSocket connection established by the call to this method. If no such mapping is
+ * defined, an empty Map must be passed.
+ *
+ * @throws IllegalStateException if the provided request does not meet the requirements of the WebSocket handshake
+ * @throws UnsupportedOperationException if the WebSocket implementation is not deployed as part of a Jakarta
+ * Servlet container
+ * @throws IOException if an I/O error occurs during the establishment of a WebSocket connection
+ * @throws DeploymentException if a configuration error prevents the establishment of a WebSocket connection
+ */
+ public void upgradeHttpToWebSocket(Object httpServletRequest, Object httpServletResponse, ServerEndpointConfig sec,
+ Map<String,String> pathParameters) throws IOException, DeploymentException;
}
diff --git a/java/org/apache/tomcat/websocket/server/WsServerContainer.java b/java/org/apache/tomcat/websocket/server/WsServerContainer.java
index e269f8b..b6949a6 100644
--- a/java/org/apache/tomcat/websocket/server/WsServerContainer.java
+++ b/java/org/apache/tomcat/websocket/server/WsServerContainer.java
@@ -313,7 +313,12 @@ public class WsServerContainer extends WsWebSocketContainer
* @throws ServletException If a configuration error prevents the upgrade
* from taking place
* @throws IOException If an I/O error occurs during the upgrade process
+ *
+ * @deprecated This method will be removed in Apache Tomcat 10.1 onwards. It
+ * has been replaced by {@link #upgradeHttpToWebSocket(Object,
+ * Object, ServerEndpointConfig, Map)}
*/
+ @Deprecated
public void doUpgrade(HttpServletRequest request,
HttpServletResponse response, ServerEndpointConfig sec,
Map<String,String> pathParams)
@@ -322,6 +327,19 @@ public class WsServerContainer extends WsWebSocketContainer
}
+ @Override
+ public void upgradeHttpToWebSocket(Object httpServletRequest, Object httpServletResponse,
+ ServerEndpointConfig sec, Map<String, String> pathParameters)
+ throws IOException, DeploymentException {
+ try {
+ UpgradeUtil.doUpgrade(this, (HttpServletRequest) httpServletRequest, (HttpServletResponse) httpServletResponse,
+ sec, pathParameters);
+ } catch (ServletException e) {
+ throw new DeploymentException(e.getMessage(), e);
+ }
+ }
+
+
public WsMappingResult findMapping(String path) {
// Prevent registering additional endpoints once the first attempt has
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index e0a9205..589e0fa 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -139,6 +139,11 @@
</code>to align with recent updates in the WebSocket specification
project. (markt)
</update>
+ <update>
+ Add a new method <code>ServerContainer.upgradeHttpToWebSocket()</code>
+ to align with recent updates in the WebSocket specification project.
+ (markt)
+ </update>
</changelog>
</subsection>
</section>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org