Class UpgradeRequestAdapter
- java.lang.Object
-
- org.eclipse.jetty.websocket.common.UpgradeRequestAdapter
-
- All Implemented Interfaces:
UpgradeRequest
- Direct Known Subclasses:
ClientUpgradeRequest
public class UpgradeRequestAdapter extends java.lang.Object implements UpgradeRequest
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
UpgradeRequestAdapter()
UpgradeRequestAdapter(java.lang.String requestURI)
UpgradeRequestAdapter(java.net.URI requestURI)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addExtensions(java.lang.String... configs)
Add WebSocket Extension Configuration(s) to requestvoid
addExtensions(ExtensionConfig... configs)
Add WebSocket Extension Configuration(s) to Upgrade Request.void
clearHeaders()
Remove all headers from request.java.util.List<java.net.HttpCookie>
getCookies()
Get the list of Cookies on the Upgrade requestjava.util.List<ExtensionConfig>
getExtensions()
Get the list of WebSocket Extension Configurations for this Upgrade Request.java.lang.String
getHeader(java.lang.String name)
Get a specific Header value from Upgrade Requestint
getHeaderInt(java.lang.String name)
Get the specific Header value, as anint
, from the Upgrade Request.java.util.Map<java.lang.String,java.util.List<java.lang.String>>
getHeaders()
Get the headers as a Map of keys to value lists.java.util.List<java.lang.String>
getHeaders(java.lang.String name)
Get the specific header values (for multi-value headers)java.lang.String
getHost()
The host of the Upgrade Request URIjava.lang.String
getHttpVersion()
The HTTP version used for this Upgrade Requestjava.lang.String
getMethod()
The HTTP method for this Upgrade Request.java.lang.String
getOrigin()
The WebSocket Origin of this Upgrade Requestjava.util.Map<java.lang.String,java.util.List<java.lang.String>>
getParameterMap()
Returns a map of the query parameters of the request.java.lang.String
getProtocolVersion()
Get the WebSocket Protocol Versionjava.lang.String
getQueryString()
Get the Query String of the request URI.java.net.URI
getRequestURI()
Get the Request URIjava.lang.Object
getSession()
Access the Servlet HTTP Session (if present)java.util.List<java.lang.String>
getSubProtocols()
Get the list of offered WebSocket sub-protocols.java.security.Principal
getUserPrincipal()
Get the User Principal for this request.boolean
hasSubProtocol(java.lang.String test)
Test if a specific sub-protocol is offeredboolean
isOrigin(java.lang.String test)
Test if supplied Origin is the same as the Requestboolean
isSecure()
Test if connection is secure.void
setCookies(java.util.List<java.net.HttpCookie> cookies)
Set the list of Cookies on the requestvoid
setExtensions(java.util.List<ExtensionConfig> configs)
Set the list of WebSocket Extension configurations on the request.void
setHeader(java.lang.String name, java.lang.String value)
Set a specific header valuevoid
setHeader(java.lang.String name, java.util.List<java.lang.String> values)
Set a specific header with multi-value fieldvoid
setHeaders(java.util.Map<java.lang.String,java.util.List<java.lang.String>> headers)
Sets multiple headers on the request.void
setHttpVersion(java.lang.String httpVersion)
Set the HTTP Version to use.void
setMethod(java.lang.String method)
Set the HTTP method to use.protected void
setParameterMap(java.util.Map<java.lang.String,java.util.List<java.lang.String>> parameters)
void
setRequestURI(java.net.URI uri)
Set the Request URI to use for this request.void
setSession(java.lang.Object session)
Set the Session associated with this request.void
setSubProtocols(java.lang.String... protocols)
Set Sub Protocol request list.void
setSubProtocols(java.util.List<java.lang.String> subProtocols)
Set the offered WebSocket Sub-Protocol list.
-
-
-
Method Detail
-
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 interfaceUpgradeRequest
- Parameters:
configs
- the configuration(s) to add
-
addExtensions
public void addExtensions(java.lang.String... configs)
Description copied from interface:UpgradeRequest
Add WebSocket Extension Configuration(s) to requestThis is merely the list of requested Extensions to use, see
UpgradeResponse.getExtensions()
for what was negotiated- Specified by:
addExtensions
in interfaceUpgradeRequest
- 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 interfaceUpgradeRequest
-
getCookies
public java.util.List<java.net.HttpCookie> getCookies()
Description copied from interface:UpgradeRequest
Get the list of Cookies on the Upgrade request- Specified by:
getCookies
in interfaceUpgradeRequest
- Returns:
- the list of Cookies
-
getExtensions
public java.util.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 interfaceUpgradeRequest
- Returns:
- the list of Extension configurations (in the order they were specified)
-
getHeader
public java.lang.String getHeader(java.lang.String name)
Description copied from interface:UpgradeRequest
Get a specific Header value from Upgrade Request- Specified by:
getHeader
in interfaceUpgradeRequest
- Parameters:
name
- the name of the header- Returns:
- the value of the header (null if header does not exist)
-
getHeaderInt
public int getHeaderInt(java.lang.String name)
Description copied from interface:UpgradeRequest
Get the specific Header value, as anint
, from the Upgrade Request.- Specified by:
getHeaderInt
in interfaceUpgradeRequest
- Parameters:
name
- the name of the header- Returns:
- the value of the header as an
int
(-1 if header does not exist)
-
getHeaders
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getHeaders()
Description copied from interface:UpgradeRequest
Get the headers as a Map of keys to value lists.- Specified by:
getHeaders
in interfaceUpgradeRequest
- Returns:
- the headers
-
getHeaders
public java.util.List<java.lang.String> getHeaders(java.lang.String name)
Description copied from interface:UpgradeRequest
Get the specific header values (for multi-value headers)- Specified by:
getHeaders
in interfaceUpgradeRequest
- Parameters:
name
- the header name- Returns:
- the value list (null if no header exists)
-
getHost
public java.lang.String getHost()
Description copied from interface:UpgradeRequest
The host of the Upgrade Request URI- Specified by:
getHost
in interfaceUpgradeRequest
- Returns:
- host of the request URI
-
getHttpVersion
public java.lang.String getHttpVersion()
Description copied from interface:UpgradeRequest
The HTTP version used for this Upgrade RequestAs of RFC6455 (December 2011) this is always
HTTP/1.1
- Specified by:
getHttpVersion
in interfaceUpgradeRequest
- Returns:
- the HTTP Version used
-
getMethod
public java.lang.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 interfaceUpgradeRequest
- Returns:
- the HTTP method used
-
getOrigin
public java.lang.String getOrigin()
Description copied from interface:UpgradeRequest
The WebSocket Origin of this Upgrade RequestSee RFC6455: Section 10.2 for details.
Equivalent to
UpgradeRequest.getHeader(String)
passed the "Origin" header.- Specified by:
getOrigin
in interfaceUpgradeRequest
- Returns:
- the Origin header
-
getParameterMap
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getParameterMap()
Returns a map of the query parameters of the request.- Specified by:
getParameterMap
in interfaceUpgradeRequest
- Returns:
- a unmodifiable map of query parameters of the request.
-
getProtocolVersion
public java.lang.String getProtocolVersion()
Description copied from interface:UpgradeRequest
Get the WebSocket Protocol VersionAs of RFC6455, Jetty only supports version
13
- Specified by:
getProtocolVersion
in interfaceUpgradeRequest
- Returns:
- the WebSocket protocol version
-
getQueryString
public java.lang.String getQueryString()
Description copied from interface:UpgradeRequest
Get the Query String of the request URI.- Specified by:
getQueryString
in interfaceUpgradeRequest
- Returns:
- the request uri query string
-
getRequestURI
public java.net.URI getRequestURI()
Description copied from interface:UpgradeRequest
Get the Request URI- Specified by:
getRequestURI
in interfaceUpgradeRequest
- Returns:
- the request URI
-
getSession
public java.lang.Object getSession()
Access the Servlet HTTP Session (if present)Note: Never present on a Client UpgradeRequest.
- Specified by:
getSession
in interfaceUpgradeRequest
- Returns:
- the Servlet HTTPSession on server side UpgradeRequests
-
getSubProtocols
public java.util.List<java.lang.String> getSubProtocols()
Description copied from interface:UpgradeRequest
Get the list of offered WebSocket sub-protocols.- Specified by:
getSubProtocols
in interfaceUpgradeRequest
- Returns:
- the list of offered sub-protocols
-
getUserPrincipal
public java.security.Principal getUserPrincipal()
Get the User Principal for this request.Only applicable when using UpgradeRequest from server side.
- Specified by:
getUserPrincipal
in interfaceUpgradeRequest
- Returns:
- the user principal
-
hasSubProtocol
public boolean hasSubProtocol(java.lang.String test)
Description copied from interface:UpgradeRequest
Test if a specific sub-protocol is offered- Specified by:
hasSubProtocol
in interfaceUpgradeRequest
- Parameters:
test
- the sub-protocol to test for- Returns:
- true if sub-protocol exists on request
-
isOrigin
public boolean isOrigin(java.lang.String test)
Description copied from interface:UpgradeRequest
Test if supplied Origin is the same as the Request- Specified by:
isOrigin
in interfaceUpgradeRequest
- 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 interfaceUpgradeRequest
- Returns:
- true if connection is secure.
-
setCookies
public void setCookies(java.util.List<java.net.HttpCookie> cookies)
Description copied from interface:UpgradeRequest
Set the list of Cookies on the request- Specified by:
setCookies
in interfaceUpgradeRequest
- Parameters:
cookies
- the cookies to use
-
setExtensions
public void setExtensions(java.util.List<ExtensionConfig> configs)
Description copied from interface:UpgradeRequest
Set the list of WebSocket Extension configurations on the request.- Specified by:
setExtensions
in interfaceUpgradeRequest
- Parameters:
configs
- the list of extension configurations
-
setHeader
public void setHeader(java.lang.String name, java.util.List<java.lang.String> values)
Description copied from interface:UpgradeRequest
Set a specific header with multi-value fieldOverrides any previous value for this named header
- Specified by:
setHeader
in interfaceUpgradeRequest
- Parameters:
name
- the name of the headervalues
- the multi-value field
-
setHeader
public void setHeader(java.lang.String name, java.lang.String value)
Description copied from interface:UpgradeRequest
Set a specific header valueOverrides any previous value for this named header
- Specified by:
setHeader
in interfaceUpgradeRequest
- Parameters:
name
- the header to setvalue
- the value to set it to
-
setHeaders
public void setHeaders(java.util.Map<java.lang.String,java.util.List<java.lang.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 interfaceUpgradeRequest
- Parameters:
headers
- the headers to set
-
setHttpVersion
public void setHttpVersion(java.lang.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 interfaceUpgradeRequest
- Parameters:
httpVersion
- the HTTP version to use.
-
setMethod
public void setMethod(java.lang.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 interfaceUpgradeRequest
- Parameters:
method
- the HTTP method to use.
-
setParameterMap
protected void setParameterMap(java.util.Map<java.lang.String,java.util.List<java.lang.String>> parameters)
-
setRequestURI
public void setRequestURI(java.net.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 interfaceUpgradeRequest
- Parameters:
uri
- the Request URI
-
setSession
public void setSession(java.lang.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 interfaceUpgradeRequest
- Parameters:
session
- the session object to associate with this request
-
setSubProtocols
public void setSubProtocols(java.util.List<java.lang.String> subProtocols)
Description copied from interface:UpgradeRequest
Set the offered WebSocket Sub-Protocol list.- Specified by:
setSubProtocols
in interfaceUpgradeRequest
- Parameters:
subProtocols
- the offered sub-protocol list
-
setSubProtocols
public void setSubProtocols(java.lang.String... protocols)
Set Sub Protocol request list.- Specified by:
setSubProtocols
in interfaceUpgradeRequest
- Parameters:
protocols
- the sub protocols desired
-
-