Class UpgradeUtil
- java.lang.Object
-
- org.apache.tomcat.websocket.server.UpgradeUtil
-
public class UpgradeUtil extends java.lang.ObjectUtility methods for handling WebSocket upgrade requests.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voiddoUpgrade(WsServerContainer sc, HttpServletRequest req, HttpServletResponse resp, ServerEndpointConfig sec, java.util.Map<java.lang.String,java.lang.String> pathParams)Performs the WebSocket upgrade handshake.static booleanisWebSocketUpgradeRequest(ServletRequest request, ServletResponse response)Checks to see if this is an HTTP request that includes a valid upgrade request to web socket.
-
-
-
Method Detail
-
isWebSocketUpgradeRequest
public static boolean isWebSocketUpgradeRequest(ServletRequest request, ServletResponse response)
Checks to see if this is an HTTP request that includes a valid upgrade request to web socket.Note: RFC 2616 does not limit HTTP upgrade to GET requests but the Java WebSocket spec 1.0, section 8.2 implies such a limitation and RFC 6455 section 4.1 requires that a WebSocket Upgrade uses GET.
- Parameters:
request- The request to check if it is an HTTP upgrade request for a WebSocket connectionresponse- The response associated with the request- Returns:
trueif the request includes an HTTP Upgrade request for the WebSocket protocol, otherwisefalse
-
doUpgrade
public static void doUpgrade(WsServerContainer sc, HttpServletRequest req, HttpServletResponse resp, ServerEndpointConfig sec, java.util.Map<java.lang.String,java.lang.String> pathParams) throws ServletException, java.io.IOException
Performs the WebSocket upgrade handshake.- Parameters:
sc- the server containerreq- the HTTP requestresp- the HTTP responsesec- the endpoint configurationpathParams- the path parameters- Throws:
ServletException- if the upgrade failsjava.io.IOException- if an I/O error occurs
-
-