Interface JettyServerUpgradeResponse

All Superinterfaces:
UpgradeResponse
All Known Implementing Classes:
DelegatedServerUpgradeResponse

public interface JettyServerUpgradeResponse extends UpgradeResponse
  • Method Details

    • addHeader

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

      void setHeader(String name, String value)
      Set a header

      Overrides previous value of header (if set)

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

      void setHeader(String name, List<String> values)
      Set a header

      Overrides previous value of header (if set)

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

      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.

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

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

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

      void setExtensions(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.
      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.