Class UpgradeResponseAdapter

    • Field Detail

      • SEC_WEBSOCKET_PROTOCOL

        public static final java.lang.String SEC_WEBSOCKET_PROTOCOL
        See Also:
        Constant Field Values
    • Constructor Detail

      • UpgradeResponseAdapter

        public UpgradeResponseAdapter()
    • Method Detail

      • addHeader

        public void addHeader​(java.lang.String name,
                              java.lang.String value)
        Specified by:
        addHeader in interface UpgradeResponse
      • getAcceptedSubProtocol

        public java.lang.String getAcceptedSubProtocol()
        Get the accepted WebSocket protocol.
        Specified by:
        getAcceptedSubProtocol in interface UpgradeResponse
        Returns:
        the accepted WebSocket protocol.
      • getExtensions

        public java.util.List<ExtensionConfig> getExtensions()
        Get the list of extensions that should be used for the websocket.
        Specified by:
        getExtensions in interface UpgradeResponse
        Returns:
        the list of negotiated extensions to use.
      • getHeader

        public java.lang.String getHeader​(java.lang.String name)
        Specified by:
        getHeader in interface UpgradeResponse
      • getHeaders

        public java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getHeaders()
        Specified by:
        getHeaders in interface UpgradeResponse
      • getHeaders

        public java.util.List<java.lang.String> getHeaders​(java.lang.String name)
        Specified by:
        getHeaders in interface UpgradeResponse
      • sendForbidden

        public void sendForbidden​(java.lang.String message)
                           throws java.io.IOException
        Issue a forbidden upgrade response.

        This means that the websocket endpoint was valid, but the conditions to use a WebSocket resulted in a forbidden access.

        Use this when the origin or authentication is invalid.

        Specified by:
        sendForbidden in interface UpgradeResponse
        Parameters:
        message - the short 1 line detail message about the forbidden response
        Throws:
        java.io.IOException - if unable to send the forbidden
      • setAcceptedSubProtocol

        public void setAcceptedSubProtocol​(java.lang.String protocol)
        Set the accepted WebSocket Protocol.
        Specified by:
        setAcceptedSubProtocol in interface UpgradeResponse
        Parameters:
        protocol - the protocol to list as accepted
      • setExtensions

        public void setExtensions​(java.util.List<ExtensionConfig> extensions)
        Set the list of extensions that are approved for use with this websocket.

        Notes:

        • Per the spec you cannot add extensions that have not been seen in the UpgradeRequest, just remove entries you don't want to use
        • If this is unused, or a null is passed, then the list negotiation will follow default behavior and use the complete list of extensions that are available in this WebSocket server implementation.
        Specified by:
        setExtensions in interface UpgradeResponse
        Parameters:
        extensions - the list of extensions to use.
      • setHeader

        public void setHeader​(java.lang.String name,
                              java.lang.String value)
        Specified by:
        setHeader in interface UpgradeResponse