Class HandshakerSelector

java.lang.Object
org.eclipse.jetty.websocket.core.server.internal.HandshakerSelector
All Implemented Interfaces:
Handshaker

public class HandshakerSelector extends Object implements Handshaker
Selects between the two Handshaker implementations, RFC6455 (HTTP/1.1 WebSocket Upgrades) and RFC68441 (HTTP/2 WebSocket Upgrades)
  • Constructor Details

    • HandshakerSelector

      public HandshakerSelector()
  • Method Details

    • isWebSocketUpgradeRequest

      public boolean isWebSocketUpgradeRequest(Request request)
      Description copied from interface: Handshaker

      A preliminary check to see if a request is likely to be a valid WebSocket Upgrade Request. If this returns true the Request may be a valid upgrade request, but if this returns false returns false you can avoid calling Handshaker.upgradeRequest(WebSocketNegotiator, Request, Response, Callback, WebSocketComponents, Configuration.Customizer) entirely as it will always fail

      Specified by:
      isWebSocketUpgradeRequest in interface Handshaker
      Parameters:
      request - the request
      Returns:
      true if the request is thought to be a valid websocket upgrade request.
    • upgradeRequest

      public boolean upgradeRequest(WebSocketNegotiator negotiator, Request request, Response response, Callback callback, WebSocketComponents components, Configuration.Customizer defaultCustomizer) throws WebSocketException
      Description copied from interface: Handshaker

      Attempts to upgrade a request to WebSocket.

      Returns true if the WebSocket upgrade is successful and a successful response is generated and the callback eventually completed, or if the WebSocket upgrade failed and a failure response is generated and the callback eventually completed. Returns false if a response is not generated and the caller is responsible for generating a response and completing the callback.

      Specified by:
      upgradeRequest in interface Handshaker
      Parameters:
      negotiator - the negotiator
      request - the request
      response - the response
      callback - the callback
      components - the WebSocket components
      defaultCustomizer - the customizer
      Returns:
      true if a response was generated, false if a response is not generated
      Throws:
      WebSocketException - there is an error during the upgrade