Class WsServerContainer

    • Method Detail

      • doUpgrade

        @Deprecated
        public void doUpgrade​(HttpServletRequest request,
                              HttpServletResponse response,
                              ServerEndpointConfig sec,
                              Map<String,​String> pathParams)
                       throws ServletException,
                              IOException
        Deprecated.
        This method will be removed in Apache Tomcat 10.1 onwards. It has been replaced by upgradeHttpToWebSocket(Object, Object, ServerEndpointConfig, Map)
        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.

        Note: This method is not used by Tomcat but is used directly by third-party code and must not be removed.

        Parameters:
        request - The request object to be upgraded
        response - The response object to be populated with the result of the upgrade
        sec - The server endpoint to use to process the upgrade request
        pathParams - The path parameters associated with the upgrade request
        Throws:
        ServletException - If a configuration error prevents the upgrade from taking place
        IOException - If an I/O error occurs during the upgrade process
      • upgradeHttpToWebSocket

        public void upgradeHttpToWebSocket​(Object httpServletRequest,
                                           Object httpServletResponse,
                                           ServerEndpointConfig sec,
                                           Map<String,​String> pathParameters)
                                    throws IOException,
                                           DeploymentException
        Upgrade the HTTP connection represented by the HttpServletRequest and HttpServletResponse to the WebSocket protocol and establish a WebSocket connection as per the provided ServerEndpointConfig.

        This method is primarily intended to be used by frameworks that implement the front-controller pattern. It does not deploy the provided endpoint.

        If the WebSocket implementation is not deployed as part of a Jakarta Servlet container, this method will throw an UnsupportedOperationException.

        This method will be part of the Jakarta WebSocket API from version 2.1

        Parameters:
        httpServletRequest - The HttpServletRequest to be processed as a WebSocket handshake as per section 4.0 of RFC 6455.
        httpServletResponse - The HttpServletResponse to be used when processing the httpServletRequest as a WebSocket handshake as per section 4.0 of RFC 6455.
        sec - The server endpoint configuration to use to configure the WebSocket endpoint
        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
        UnsupportedOperationException - if the WebSocket implementation is not deployed as part of a Jakarta Servlet container
        IOException - if an I/O error occurs during the establishment of a WebSocket connection
        DeploymentException - if a configuration error prevents the establishment of a WebSocket connection
      • findMapping

        public org.apache.tomcat.websocket.server.WsMappingResult findMapping​(String path)
      • isEnforceNoAddAfterHandshake

        @Deprecated
        public boolean isEnforceNoAddAfterHandshake()
        Deprecated.
      • setEnforceNoAddAfterHandshake

        @Deprecated
        public void setEnforceNoAddAfterHandshake​(boolean enforceNoAddAfterHandshake)
        Deprecated.
      • closeAuthenticatedSession

        public void closeAuthenticatedSession​(String httpSessionId)