Top Fields Constructors Methods
org.apache.tomcat.websocket.server

public Class UpgradeUtil

extends Object
Class Inheritance
Imports
java.io.IOException, java.nio.charset.StandardCharsets, java.util.ArrayList, .Collections, .Enumeration, .LinkedHashMap, .List, .Map, .Map.Entry, jakarta.servlet.ServletException, .ServletRequest, .ServletResponse, jakarta.servlet.http.HttpServletRequest, .HttpServletResponse, jakarta.websocket.DeploymentException, .Endpoint, .Extension, .HandshakeResponse, jakarta.websocket.server.ServerEndpointConfig, org.apache.tomcat.util.codec.binary.Base64, org.apache.tomcat.util.res.StringManager, org.apache.tomcat.util.security.ConcurrentMessageDigest, org.apache.tomcat.websocket.Constants, .Transformation, .TransformationFactory, .Util, .WsHandshakeResponse, org.apache.tomcat.websocket.pojo.PojoMethodMapping

Field Summary

Modifier and TypeField and Description
private static final StringManager
private static final byte[]

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static void
private static List<Transformation>
createTransformations(List<Extension> negotiatedExtensions)

public static void
private static List<String>
private static String
private static boolean
public static boolean

Returns:

true if the request includes an HTTP Upgrade request for the WebSocket protocol, otherwise false
isWebSocketUpgradeRequest
(ServletRequest
The request to check if it is an HTTP upgrade request for a WebSocket connection
request
,
ServletResponse
The response associated with the request
response
)

Checks to see if this is an HTTP request that includes a valid upgrade request to web socket.

private static boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

smback to summary
private static final StringManager sm
WS_ACCEPTback to summary
private static final byte[] WS_ACCEPT

Constructor Detail

UpgradeUtilback to summary
private UpgradeUtil()

Method Detail

appendback to summary
private static void append(StringBuilder sb, Extension extension)
createTransformationsback to summary
private static List<Transformation> createTransformations(List<Extension> negotiatedExtensions)
doUpgradeback to summary
public static void doUpgrade(WsServerContainer sc, HttpServletRequest req, HttpServletResponse resp, ServerEndpointConfig sec, Map<String, String> pathParams) throws ServletException, IOException
getTokensFromHeaderback to summary
private static List<String> getTokensFromHeader(HttpServletRequest req, String headerName)
getWebSocketAcceptback to summary
private static String getWebSocketAccept(String key)
headerContainsTokenback to summary
private static boolean headerContainsToken(HttpServletRequest req, String headerName, String target)
isWebSocketUpgradeRequestback to summary
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:ServletRequest

The request to check if it is an HTTP upgrade request for a WebSocket connection

response:ServletResponse

The response associated with the request

Returns:boolean

true if the request includes an HTTP Upgrade request for the WebSocket protocol, otherwise false

validateKeyback to summary
private static boolean validateKey(String key)