Class WebSocketUpgrade


  • public class WebSocketUpgrade
    extends Object
    Represents a web socket upgrade request.
    • Constructor Detail

      • WebSocketUpgrade

        public WebSocketUpgrade​(String hostName,
                                String webSocketPath,
                                String webSocketQuery,
                                int webSocketPort,
                                String webSocketProtocol,
                                Map<String,​String> additionalHeaders)
        Create WebSocketUpgrade instance, which can be used for websocket upgrade hand-shake with http server as per RFC https://tools.ietf.org/html/rfc6455.
        Parameters:
        hostName - host name to send the request to
        webSocketPath - path on the request url where WebSocketUpgrade will be sent to
        webSocketQuery - query on the request url where WebSocketUpgrade will be sent to
        webSocketPort - port on the request url where WebSocketUpgrade will be sent to
        webSocketProtocol - value for Sec-WebSocket-Protocol header on the WebSocketUpgrade request
        additionalHeaders - any additional headers to be part of the WebSocketUpgrade request
    • Method Detail

      • createUpgradeRequest

        public String createUpgradeRequest()
        Create the Upgrade to websocket request as per the RFC https://tools.ietf.org/html/rfc6455.
        Returns:
        http request to upgrade to websockets.
      • validateUpgradeReply

        public Boolean validateUpgradeReply​(byte[] responseBytes)
        Validate the response received for 'upgrade to websockets' request from http server.
        Parameters:
        responseBytes - bytes received from http server
        Returns:
        value indicating if the websockets upgrade succeeded