Class UpgradeResponseAdapter

  • All Implemented Interfaces:
    org.eclipse.jetty.websocket.api.UpgradeResponse

    public class UpgradeResponseAdapter
    extends Object
    implements org.eclipse.jetty.websocket.api.UpgradeResponse
    • Constructor Detail

      • UpgradeResponseAdapter

        public UpgradeResponseAdapter()
    • Method Detail

      • addHeader

        public void addHeader​(String name,
                              String value)
        Specified by:
        addHeader in interface org.eclipse.jetty.websocket.api.UpgradeResponse
      • getAcceptedSubProtocol

        public String getAcceptedSubProtocol()
        Get the accepted WebSocket protocol.
        Specified by:
        getAcceptedSubProtocol in interface org.eclipse.jetty.websocket.api.UpgradeResponse
        Returns:
        the accepted WebSocket protocol.
      • getExtensions

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

        public String getHeader​(String name)
        Specified by:
        getHeader in interface org.eclipse.jetty.websocket.api.UpgradeResponse
      • getHeaderNames

        public Set<String> getHeaderNames()
        Specified by:
        getHeaderNames in interface org.eclipse.jetty.websocket.api.UpgradeResponse
      • getHeaders

        public Map<String,​List<String>> getHeaders()
        Specified by:
        getHeaders in interface org.eclipse.jetty.websocket.api.UpgradeResponse
      • getHeaders

        public List<String> getHeaders​(String name)
        Specified by:
        getHeaders in interface org.eclipse.jetty.websocket.api.UpgradeResponse
      • getStatusCode

        public int getStatusCode()
        Specified by:
        getStatusCode in interface org.eclipse.jetty.websocket.api.UpgradeResponse
      • getStatusReason

        public String getStatusReason()
        Specified by:
        getStatusReason in interface org.eclipse.jetty.websocket.api.UpgradeResponse
      • isSuccess

        public boolean isSuccess()
        Specified by:
        isSuccess in interface org.eclipse.jetty.websocket.api.UpgradeResponse
      • sendForbidden

        public void sendForbidden​(String message)
                           throws 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 org.eclipse.jetty.websocket.api.UpgradeResponse
        Parameters:
        message - the short 1 line detail message about the forbidden response
        Throws:
        IOException - if unable to send the forbidden
      • setAcceptedSubProtocol

        public void setAcceptedSubProtocol​(String protocol)
        Set the accepted WebSocket Protocol.
        Specified by:
        setAcceptedSubProtocol in interface org.eclipse.jetty.websocket.api.UpgradeResponse
        Parameters:
        protocol - the protocol to list as accepted
      • setExtensions

        public void setExtensions​(List<org.eclipse.jetty.websocket.api.extensions.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 org.eclipse.jetty.websocket.api.UpgradeResponse
        Parameters:
        extensions - the list of extensions to use.
      • setHeader

        public void setHeader​(String name,
                              String value)
        Specified by:
        setHeader in interface org.eclipse.jetty.websocket.api.UpgradeResponse
      • setStatusCode

        public void setStatusCode​(int statusCode)
        Specified by:
        setStatusCode in interface org.eclipse.jetty.websocket.api.UpgradeResponse
      • setStatusReason

        public void setStatusReason​(String statusReason)
        Specified by:
        setStatusReason in interface org.eclipse.jetty.websocket.api.UpgradeResponse
      • setSuccess

        public void setSuccess​(boolean success)
        Specified by:
        setSuccess in interface org.eclipse.jetty.websocket.api.UpgradeResponse