Interface JettyServerUpgradeResponse

  • All Superinterfaces:
    org.eclipse.jetty.websocket.api.UpgradeResponse

    public interface JettyServerUpgradeResponse
    extends org.eclipse.jetty.websocket.api.UpgradeResponse
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addHeader​(java.lang.String name, java.lang.String value)
      Add a header value to the response.
      boolean isCommitted()
      Returns a boolean indicating if the response has been committed.
      void sendError​(int statusCode, java.lang.String message)
      Sends an error response to the client using the specified status.
      void sendForbidden​(java.lang.String message)
      Issue a forbidden upgrade response.
      void setAcceptedSubProtocol​(java.lang.String protocol)
      Set the accepted WebSocket Protocol.
      void setExtensions​(java.util.List<org.eclipse.jetty.websocket.api.ExtensionConfig> extensions)
      Set the list of extensions that are approved for use with this websocket.
      void setHeader​(java.lang.String name, java.lang.String value)
      Set a header
      void setHeader​(java.lang.String name, java.util.List<java.lang.String> values)
      Set a header
      void setStatusCode​(int statusCode)
      Set the HTTP Response status code
      • Methods inherited from interface org.eclipse.jetty.websocket.api.UpgradeResponse

        getAcceptedSubProtocol, getExtensions, getHeader, getHeaderNames, getHeaders, getHeaders, getStatusCode
    • Method Detail

      • addHeader

        void addHeader​(java.lang.String name,
                       java.lang.String value)
        Add a header value to the response.
        Parameters:
        name - the header name
        value - the header value
      • setHeader

        void setHeader​(java.lang.String name,
                       java.lang.String value)
        Set a header

        Overrides previous value of header (if set)

        Parameters:
        name - the header name
        value - the header value
      • setHeader

        void setHeader​(java.lang.String name,
                       java.util.List<java.lang.String> values)
        Set a header

        Overrides previous value of header (if set)

        Parameters:
        name - the header name
        values - the header values
      • sendForbidden

        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.

        Parameters:
        message - the short 1 line detail message about the forbidden response
        Throws:
        java.io.IOException - if unable to send the forbidden
      • sendError

        void sendError​(int statusCode,
                       java.lang.String message)
                throws java.io.IOException
        Sends an error response to the client using the specified status.
        Parameters:
        statusCode - the error status code
        message - the descriptive message
        Throws:
        java.io.IOException - If an input or output exception occurs
        java.lang.IllegalStateException - If the response was committed
      • setAcceptedSubProtocol

        void setAcceptedSubProtocol​(java.lang.String protocol)
        Set the accepted WebSocket Protocol.
        Parameters:
        protocol - the protocol to list as accepted
      • setExtensions

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

        void setStatusCode​(int statusCode)
        Set the HTTP Response status code
        Parameters:
        statusCode - the status code
      • isCommitted

        boolean isCommitted()
        Returns a boolean indicating if the response has been committed. A committed response has already had its status code and headers written.
        Returns:
        a boolean indicating if the response has been committed.