# Interface HandshakeRequest

public interface HandshakeRequest
Represents the HTTP request that asked to be upgraded to WebSocket.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `SEC_WEBSOCKET_EXTENSIONS`
  Name of the Sec-WebSocket-Extensions HTTP header.
  `static final String`
  `SEC_WEBSOCKET_KEY`
  Name of the Sec-WebSocket-Key HTTP header.
  `static final String`
  `SEC_WEBSOCKET_PROTOCOL`
  Name of the Sec-WebSocket-Protocol HTTP header.
  `static final String`
  `SEC_WEBSOCKET_VERSION`
  Name of the Sec-WebSocket-Version HTTP header.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Map<String, List<String>>`
  `getHeaders()`
  Returns the HTTP headers from the handshake request.
  `Object`
  `getHttpSession()`
  Get the HTTP Session object associated with this request.
  `Map<String, List<String>>`
  `getParameterMap()`
  Returns the query parameters from the handshake request.
  `String`
  `getQueryString()`
  Returns the query string from the handshake request.
  `URI`
  `getRequestURI()`
  Returns the URI of the handshake request.
  `Principal`
  `getUserPrincipal()`
  Returns the principal of the user associated with this request, or `null` if the user is not authenticated.
  `boolean`
  `isUserInRole(String role)`
  Returns whether the user associated with this request is in the given role.

- ## Field Details

  - ### SEC_WEBSOCKET_KEY

    static final String SEC_WEBSOCKET_KEY
    Name of the Sec-WebSocket-Key HTTP header.
    See Also:
      - Constant Field Values

  - ### SEC_WEBSOCKET_PROTOCOL

    static final String SEC_WEBSOCKET_PROTOCOL
    Name of the Sec-WebSocket-Protocol HTTP header.
    See Also:
      - Constant Field Values

  - ### SEC_WEBSOCKET_VERSION

    static final String SEC_WEBSOCKET_VERSION
    Name of the Sec-WebSocket-Version HTTP header.
    See Also:
      - Constant Field Values

  - ### SEC_WEBSOCKET_EXTENSIONS

    static final String SEC_WEBSOCKET_EXTENSIONS
    Name of the Sec-WebSocket-Extensions HTTP header.
    See Also:
      - Constant Field Values

- ## Method Details

  - ### getHeaders

    Map<String, List<String>> getHeaders()
    Returns the HTTP headers from the handshake request.
    Returns:
      The HTTP headers

  - ### getUserPrincipal

    Principal getUserPrincipal()
    Returns the principal of the user associated with this request, or `null` if the user is not authenticated.
    Returns:
      The user principal

  - ### getRequestURI

    URI getRequestURI()
    Returns the URI of the handshake request.
    Returns:
      The request URI

  - ### isUserInRole

    boolean isUserInRole(String role)
    Returns whether the user associated with this request is in the given role.
    Parameters:
      `role` - The role to check
    Returns:
      `true` if the user is in the specified role

  - ### getHttpSession

    Object getHttpSession()
    Get the HTTP Session object associated with this request. Object is used to avoid a direct dependency on the Servlet API.
    Returns:
      The jakarta.servlet.http.HttpSession object associated with this request, if any.

  - ### getParameterMap

    Map<String, List<String>> getParameterMap()
    Returns the query parameters from the handshake request.
    Returns:
      The query parameter map

  - ### getQueryString

    String getQueryString()
    Returns the query string from the handshake request.
    Returns:
      The query string