Class UpgradeRequestAdapter

java.lang.Object
org.eclipse.jetty.websocket.common.UpgradeRequestAdapter
All Implemented Interfaces:
UpgradeRequest
Direct Known Subclasses:
ClientUpgradeRequest

public class UpgradeRequestAdapter extends Object implements UpgradeRequest
  • Field Details

  • Constructor Details

    • UpgradeRequestAdapter

      protected UpgradeRequestAdapter()
    • UpgradeRequestAdapter

      public UpgradeRequestAdapter(String requestURI)
    • UpgradeRequestAdapter

      public UpgradeRequestAdapter(URI requestURI)
  • Method Details

    • addExtensions

      public void addExtensions(ExtensionConfig... configs)
      Description copied from interface: UpgradeRequest
      Add WebSocket Extension Configuration(s) to Upgrade Request.

      This is merely the list of requested Extensions to use, see UpgradeResponse.getExtensions() for what was negotiated

      Specified by:
      addExtensions in interface UpgradeRequest
      Parameters:
      configs - the configuration(s) to add
    • addExtensions

      public void addExtensions(String... configs)
      Description copied from interface: UpgradeRequest
      Add WebSocket Extension Configuration(s) to request

      This is merely the list of requested Extensions to use, see UpgradeResponse.getExtensions() for what was negotiated

      Specified by:
      addExtensions in interface UpgradeRequest
      Parameters:
      configs - the configuration(s) to add
    • clearHeaders

      public void clearHeaders()
      Description copied from interface: UpgradeRequest
      Remove all headers from request.
      Specified by:
      clearHeaders in interface UpgradeRequest
    • getCookies

      public List<HttpCookie> getCookies()
      Description copied from interface: UpgradeRequest
      Get the list of Cookies on the Upgrade request
      Specified by:
      getCookies in interface UpgradeRequest
      Returns:
      the list of Cookies
    • getExtensions

      public List<ExtensionConfig> getExtensions()
      Description copied from interface: UpgradeRequest
      Get the list of WebSocket Extension Configurations for this Upgrade Request.

      This is merely the list of requested Extensions to use, see UpgradeResponse.getExtensions() for what was negotiated

      Specified by:
      getExtensions in interface UpgradeRequest
      Returns:
      the list of Extension configurations (in the order they were specified)
    • getHeader

      public String getHeader(String name)
      Description copied from interface: UpgradeRequest
      Get a specific Header value from Upgrade Request
      Specified by:
      getHeader in interface UpgradeRequest
      Parameters:
      name - the name of the header
      Returns:
      the value of the header (null if header does not exist)
    • getHeaderInt

      public int getHeaderInt(String name)
      Description copied from interface: UpgradeRequest
      Get the specific Header value, as an int, from the Upgrade Request.
      Specified by:
      getHeaderInt in interface UpgradeRequest
      Parameters:
      name - the name of the header
      Returns:
      the value of the header as an int (-1 if header does not exist)
    • getHeaders

      public Map<String,List<String>> getHeaders()
      Description copied from interface: UpgradeRequest
      Get the headers as a Map of keys to value lists.
      Specified by:
      getHeaders in interface UpgradeRequest
      Returns:
      the headers
    • getHeaders

      public List<String> getHeaders(String name)
      Description copied from interface: UpgradeRequest
      Get the specific header values (for multi-value headers)
      Specified by:
      getHeaders in interface UpgradeRequest
      Parameters:
      name - the header name
      Returns:
      the value list (null if no header exists)
    • getHost

      public String getHost()
      Description copied from interface: UpgradeRequest
      The host of the Upgrade Request URI
      Specified by:
      getHost in interface UpgradeRequest
      Returns:
      host of the request URI
    • getHttpVersion

      public String getHttpVersion()
      Description copied from interface: UpgradeRequest
      The HTTP version used for this Upgrade Request

      As of RFC6455 (December 2011) this is always HTTP/1.1

      Specified by:
      getHttpVersion in interface UpgradeRequest
      Returns:
      the HTTP Version used
    • getMethod

      public String getMethod()
      Description copied from interface: UpgradeRequest
      The HTTP method for this Upgrade Request.

      As of RFC6455 (December 2011) this is always GET

      Specified by:
      getMethod in interface UpgradeRequest
      Returns:
      the HTTP method used
    • getOrigin

      public String getOrigin()
      Description copied from interface: UpgradeRequest
      The WebSocket Origin of this Upgrade Request

      See RFC6455: Section 10.2 for details.

      Equivalent to UpgradeRequest.getHeader(String) passed the "Origin" header.

      Specified by:
      getOrigin in interface UpgradeRequest
      Returns:
      the Origin header
    • getParameterMap

      public Map<String,List<String>> getParameterMap()
      Returns a map of the query parameters of the request.
      Specified by:
      getParameterMap in interface UpgradeRequest
      Returns:
      a unmodifiable map of query parameters of the request.
    • getProtocolVersion

      public String getProtocolVersion()
      Description copied from interface: UpgradeRequest
      Get the WebSocket Protocol Version

      As of RFC6455, Jetty only supports version 13

      Specified by:
      getProtocolVersion in interface UpgradeRequest
      Returns:
      the WebSocket protocol version
    • getQueryString

      public String getQueryString()
      Description copied from interface: UpgradeRequest
      Get the Query String of the request URI.
      Specified by:
      getQueryString in interface UpgradeRequest
      Returns:
      the request uri query string
    • getRequestURI

      public URI getRequestURI()
      Description copied from interface: UpgradeRequest
      Get the Request URI
      Specified by:
      getRequestURI in interface UpgradeRequest
      Returns:
      the request URI
    • getSession

      public Object getSession()
      Access the Servlet HTTP Session (if present)

      Note: Never present on a Client UpgradeRequest.

      Specified by:
      getSession in interface UpgradeRequest
      Returns:
      the Servlet HTTPSession on server side UpgradeRequests
    • getSubProtocols

      public List<String> getSubProtocols()
      Description copied from interface: UpgradeRequest
      Get the list of offered WebSocket sub-protocols.
      Specified by:
      getSubProtocols in interface UpgradeRequest
      Returns:
      the list of offered sub-protocols
    • getUserPrincipal

      public Principal getUserPrincipal()
      Get the User Principal for this request.

      Only applicable when using UpgradeRequest from server side.

      Specified by:
      getUserPrincipal in interface UpgradeRequest
      Returns:
      the user principal
    • hasSubProtocol

      public boolean hasSubProtocol(String test)
      Description copied from interface: UpgradeRequest
      Test if a specific sub-protocol is offered
      Specified by:
      hasSubProtocol in interface UpgradeRequest
      Parameters:
      test - the sub-protocol to test for
      Returns:
      true if sub-protocol exists on request
    • isOrigin

      public boolean isOrigin(String test)
      Description copied from interface: UpgradeRequest
      Test if supplied Origin is the same as the Request
      Specified by:
      isOrigin in interface UpgradeRequest
      Parameters:
      test - the supplied origin
      Returns:
      true if the supplied origin matches the request origin
    • isSecure

      public boolean isSecure()
      Description copied from interface: UpgradeRequest
      Test if connection is secure.
      Specified by:
      isSecure in interface UpgradeRequest
      Returns:
      true if connection is secure.
    • setCookies

      public void setCookies(List<HttpCookie> cookies)
      Description copied from interface: UpgradeRequest
      Set the list of Cookies on the request
      Specified by:
      setCookies in interface UpgradeRequest
      Parameters:
      cookies - the cookies to use
    • setExtensions

      public void setExtensions(List<ExtensionConfig> configs)
      Description copied from interface: UpgradeRequest
      Set the list of WebSocket Extension configurations on the request.
      Specified by:
      setExtensions in interface UpgradeRequest
      Parameters:
      configs - the list of extension configurations
    • setHeader

      public void setHeader(String name, List<String> values)
      Description copied from interface: UpgradeRequest
      Set a specific header with multi-value field

      Overrides any previous value for this named header

      Specified by:
      setHeader in interface UpgradeRequest
      Parameters:
      name - the name of the header
      values - the multi-value field
    • setHeader

      public void setHeader(String name, String value)
      Description copied from interface: UpgradeRequest
      Set a specific header value

      Overrides any previous value for this named header

      Specified by:
      setHeader in interface UpgradeRequest
      Parameters:
      name - the header to set
      value - the value to set it to
    • setHeaders

      public void setHeaders(Map<String,List<String>> headers)
      Description copied from interface: UpgradeRequest
      Sets multiple headers on the request.

      Only sets those headers provided, does not remove headers that exist on request and are not provided in the parameter for this method.

      Convenience method vs calling UpgradeRequest.setHeader(String, List) multiple times.

      Specified by:
      setHeaders in interface UpgradeRequest
      Parameters:
      headers - the headers to set
    • setHttpVersion

      public void setHttpVersion(String httpVersion)
      Description copied from interface: UpgradeRequest
      Set the HTTP Version to use.

      As of RFC6455 (December 2011) this should always be HTTP/1.1

      Specified by:
      setHttpVersion in interface UpgradeRequest
      Parameters:
      httpVersion - the HTTP version to use.
    • setMethod

      public void setMethod(String method)
      Description copied from interface: UpgradeRequest
      Set the HTTP method to use.

      As of RFC6455 (December 2011) this is always GET

      Specified by:
      setMethod in interface UpgradeRequest
      Parameters:
      method - the HTTP method to use.
    • setParameterMap

      protected void setParameterMap(Map<String,List<String>> parameters)
    • setRequestURI

      public void setRequestURI(URI uri)
      Description copied from interface: UpgradeRequest
      Set the Request URI to use for this request.

      Must be an absolute URI with scheme 'ws' or 'wss'

      Specified by:
      setRequestURI in interface UpgradeRequest
      Parameters:
      uri - the Request URI
    • setSession

      public void setSession(Object session)
      Description copied from interface: UpgradeRequest
      Set the Session associated with this request.

      Typically used to associate the Servlet HttpSession object.

      Specified by:
      setSession in interface UpgradeRequest
      Parameters:
      session - the session object to associate with this request
    • setSubProtocols

      public void setSubProtocols(List<String> subProtocols)
      Description copied from interface: UpgradeRequest
      Set the offered WebSocket Sub-Protocol list.
      Specified by:
      setSubProtocols in interface UpgradeRequest
      Parameters:
      subProtocols - the offered sub-protocol list
    • setSubProtocols

      public void setSubProtocols(String... protocols)
      Set Sub Protocol request list.
      Specified by:
      setSubProtocols in interface UpgradeRequest
      Parameters:
      protocols - the sub protocols desired