Interface UpgradeRequest
- All Known Implementing Classes:
ClientUpgradeRequest, ServletUpgradeRequest, ServletWebSocketRequest, UpgradeRequestAdapter, WebSocketUpgradeRequest.ClientUpgradeRequestFacade
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddExtensions(String... configs) Add WebSocket Extension Configuration(s) to requestvoidaddExtensions(ExtensionConfig... configs) Add WebSocket Extension Configuration(s) to Upgrade Request.voidDeprecated.(no longer supported, as this can undo the required upgrade request headers)Get the list of Cookies on the Upgrade requestGet the list of WebSocket Extension Configurations for this Upgrade Request.Get a specific Header value from Upgrade RequestintgetHeaderInt(String name) Get the specific Header value, as anint, from the Upgrade Request.Get the headers as a Map of keys to value lists.getHeaders(String name) Get the specific header values (for multi-value headers)getHost()The host of the Upgrade Request URIThe HTTP version used for this Upgrade RequestThe HTTP method for this Upgrade Request.The WebSocket Origin of this Upgrade RequestReturns a map of the query parameters of the request.Get the WebSocket Protocol VersionGet the Query String of the request URI.Get the Request URIAccess the Servlet HTTP Session (if present)Get the list of offered WebSocket sub-protocols.Get the User Principal for this request.booleanhasSubProtocol(String test) Test if a specific sub-protocol is offeredbooleanTest if supplied Origin is the same as the RequestbooleanisSecure()Test if connection is secure.voidsetCookies(List<HttpCookie> cookies) Set the list of Cookies on the requestvoidsetExtensions(List<ExtensionConfig> configs) Set the list of WebSocket Extension configurations on the request.voidSet a specific header valuevoidSet a specific header with multi-value fieldvoidsetHeaders(Map<String, List<String>> headers) Sets multiple headers on the request.voidsetHttpVersion(String httpVersion) Set the HTTP Version to use.voidSet the HTTP method to use.voidsetRequestURI(URI uri) Set the Request URI to use for this request.voidsetSession(Object session) Set the Session associated with this request.voidsetSubProtocols(String... protocols) Set the offered WebSocket Sub-Protocol list.voidsetSubProtocols(List<String> protocols) Set the offered WebSocket Sub-Protocol list.
-
Method Details
-
addExtensions
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- Parameters:
configs- the configuration(s) to add
-
addExtensions
Add WebSocket Extension Configuration(s) to requestThis is merely the list of requested Extensions to use, see
UpgradeResponse.getExtensions()for what was negotiated- Parameters:
configs- the configuration(s) to add
-
clearHeaders
Deprecated.(no longer supported, as this can undo the required upgrade request headers)Remove all headers from request. -
getCookies
List<HttpCookie> getCookies()Get the list of Cookies on the Upgrade request- Returns:
- the list of Cookies
-
getExtensions
List<ExtensionConfig> getExtensions()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- Returns:
- the list of Extension configurations (in the order they were specified)
-
getHeader
-
getHeaderInt
Get the specific Header value, as anint, from the Upgrade Request.- Parameters:
name- the name of the header- Returns:
- the value of the header as an
int(-1 if header does not exist) - Throws:
NumberFormatException- if unable to parse value as an int.
-
getHeaders
-
getHeaders
-
getHost
-
getHttpVersion
String getHttpVersion()The HTTP version used for this Upgrade RequestAs of RFC6455 (December 2011) this is always
HTTP/1.1- Returns:
- the HTTP Version used
-
getMethod
String getMethod()The HTTP method for this Upgrade Request.As of RFC6455 (December 2011) this is always
GET- Returns:
- the HTTP method used
-
getOrigin
String getOrigin()The WebSocket Origin of this Upgrade RequestSee RFC6455: Section 10.2 for details.
Equivalent to
getHeader(String)passed the "Origin" header.- Returns:
- the Origin header
-
getParameterMap
-
getProtocolVersion
-
getQueryString
String getQueryString()Get the Query String of the request URI.- Returns:
- the request uri query string
-
getRequestURI
-
getSession
Object getSession()Access the Servlet HTTP Session (if present)Note: Never present on a Client UpgradeRequest.
- Returns:
- the Servlet HTTPSession on server side UpgradeRequests
-
getSubProtocols
-
getUserPrincipal
Principal getUserPrincipal()Get the User Principal for this request.Only applicable when using UpgradeRequest from server side.
- Returns:
- the user principal
-
hasSubProtocol
Test if a specific sub-protocol is offered- Parameters:
test- the sub-protocol to test for- Returns:
- true if sub-protocol exists on request
-
isOrigin
Test if supplied Origin is the same as the Request- Parameters:
test- the supplied origin- Returns:
- true if the supplied origin matches the request origin
-
isSecure
boolean isSecure()Test if connection is secure.- Returns:
- true if connection is secure.
-
setCookies
Set the list of Cookies on the request- Parameters:
cookies- the cookies to use
-
setExtensions
Set the list of WebSocket Extension configurations on the request.- Parameters:
configs- the list of extension configurations
-
setHeader
-
setHeader
-
setHeaders
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
setHeader(String, List)multiple times.- Parameters:
headers- the headers to set
-
setHttpVersion
Set the HTTP Version to use.As of RFC6455 (December 2011) this should always be
HTTP/1.1- Parameters:
httpVersion- the HTTP version to use.
-
setMethod
Set the HTTP method to use.As of RFC6455 (December 2011) this is always
GET- Parameters:
method- the HTTP method to use.
-
setRequestURI
Set the Request URI to use for this request.Must be an absolute URI with scheme
'ws'or'wss'- Parameters:
uri- the Request URI
-
setSession
Set the Session associated with this request.Typically used to associate the Servlet HttpSession object.
- Parameters:
session- the session object to associate with this request
-
setSubProtocols
-
setSubProtocols
Set the offered WebSocket Sub-Protocol list.- Parameters:
protocols- the offered sub-protocol list
-