public class ServletUpgradeRequest extends Object implements UpgradeRequest
UpgradeRequest implementation.| Constructor and Description |
|---|
ServletUpgradeRequest(HttpServletRequest httpRequest) |
| Modifier and Type | Method and Description |
|---|---|
void |
addExtensions(ExtensionConfig... configs)
Add WebSocket Extension Configuration(s) to Upgrade Request.
|
void |
addExtensions(String... configs)
Add WebSocket Extension Configuration(s) to request
|
void |
clearHeaders()
Remove all headers from request.
|
void |
complete() |
X509Certificate[] |
getCertificates() |
List<HttpCookie> |
getCookies()
Get the list of Cookies on the Upgrade request
|
List<ExtensionConfig> |
getExtensions()
Get the list of WebSocket Extension Configurations for this Upgrade Request.
|
String |
getHeader(String name)
Get a specific Header value from Upgrade Request
|
int |
getHeaderInt(String name)
Get the specific Header value, as an
int, from the Upgrade Request. |
Map<String,List<String>> |
getHeaders()
Get the headers as a Map of keys to value lists.
|
List<String> |
getHeaders(String name)
Get the specific header values (for multi-value headers)
|
String |
getHost()
The host of the Upgrade Request URI
|
HttpServletRequest |
getHttpServletRequest()
Return the underlying HttpServletRequest that existed at Upgrade time.
|
String |
getHttpVersion()
The HTTP version used for this Upgrade Request
|
String |
getLocalAddress()
Equivalent to
ServletRequest.getLocalAddr() |
Locale |
getLocale()
Equivalent to
ServletRequest.getLocale() |
Enumeration<Locale> |
getLocales()
Equivalent to
ServletRequest.getLocales() |
String |
getLocalHostName()
Equivalent to
ServletRequest.getLocalName() |
int |
getLocalPort()
Equivalent to
ServletRequest.getLocalPort() |
InetSocketAddress |
getLocalSocketAddress()
Return a
InetSocketAddress for the local socket. |
String |
getMethod()
The HTTP method for this Upgrade Request.
|
String |
getOrigin()
The WebSocket Origin of this Upgrade Request
|
Map<String,List<String>> |
getParameterMap()
Returns a map of the query parameters of the request.
|
Principal |
getPrincipal()
Deprecated.
use
getUserPrincipal() instead |
String |
getProtocolVersion()
Get the WebSocket Protocol Version
|
String |
getQueryString()
Get the Query String of the request URI.
|
String |
getRemoteAddress()
Equivalent to
ServletRequest.getRemoteAddr() |
String |
getRemoteHostName()
Equivalent to
ServletRequest.getRemoteHost() |
int |
getRemotePort()
Equivalent to
ServletRequest.getRemotePort() |
InetSocketAddress |
getRemoteSocketAddress()
Return a
InetSocketAddress for the remote socket. |
String |
getRequestPath() |
URI |
getRequestURI()
Get the Request URI
|
Object |
getServletAttribute(String name) |
Map<String,Object> |
getServletAttributes() |
Map<String,List<String>> |
getServletParameters() |
HttpSession |
getSession()
Return the HttpSession if it exists.
|
List<String> |
getSubProtocols()
Get the list of offered WebSocket sub-protocols.
|
Principal |
getUserPrincipal()
Equivalent to
HttpServletRequest.getUserPrincipal() |
boolean |
hasSubProtocol(String test)
Test if a specific sub-protocol is offered
|
boolean |
isOrigin(String test)
Test if supplied Origin is the same as the Request
|
boolean |
isSecure()
Test if connection is secure.
|
boolean |
isUserInRole(String role) |
void |
setCookies(List<HttpCookie> cookies)
Set the list of Cookies on the request
|
void |
setExtensions(List<ExtensionConfig> configs)
Set the list of WebSocket Extension configurations on the request.
|
void |
setHeader(String name,
List<String> values)
Set a specific header with multi-value field
|
void |
setHeader(String name,
String value)
Set a specific header value
|
void |
setHeaders(Map<String,List<String>> headers)
Sets multiple headers on the request.
|
void |
setHttpVersion(String httpVersion)
Set the HTTP Version to use.
|
void |
setMethod(String method)
Set the HTTP method to use.
|
void |
setRequestURI(URI uri)
Set the Request URI to use for this request.
|
void |
setServletAttribute(String name,
Object value) |
void |
setSession(Object session)
Set the Session associated with this request.
|
void |
setSubProtocols(List<String> subProtocols)
Set the offered WebSocket Sub-Protocol list.
|
void |
setSubProtocols(String... protocols)
Set the offered WebSocket Sub-Protocol list.
|
public ServletUpgradeRequest(HttpServletRequest httpRequest) throws URISyntaxException
URISyntaxExceptionpublic void addExtensions(ExtensionConfig... configs)
UpgradeRequest
This is merely the list of requested Extensions to use, see UpgradeResponse.getExtensions() for what was
negotiated
addExtensions in interface UpgradeRequestconfigs - the configuration(s) to addpublic void addExtensions(String... configs)
UpgradeRequest
This is merely the list of requested Extensions to use, see UpgradeResponse.getExtensions() for what was
negotiated
addExtensions in interface UpgradeRequestconfigs - the configuration(s) to addpublic void clearHeaders()
UpgradeRequestclearHeaders in interface UpgradeRequestpublic void complete()
public X509Certificate[] getCertificates()
public List<HttpCookie> getCookies()
UpgradeRequestgetCookies in interface UpgradeRequestpublic List<ExtensionConfig> getExtensions()
UpgradeRequest
This is merely the list of requested Extensions to use, see UpgradeResponse.getExtensions() for what was
negotiated
getExtensions in interface UpgradeRequestpublic String getHeader(String name)
UpgradeRequestgetHeader in interface UpgradeRequestname - the name of the headerpublic int getHeaderInt(String name)
UpgradeRequestint, from the Upgrade Request.getHeaderInt in interface UpgradeRequestname - the name of the headerint (-1 if header does not exist)public Map<String,List<String>> getHeaders()
UpgradeRequestgetHeaders in interface UpgradeRequestpublic List<String> getHeaders(String name)
UpgradeRequestgetHeaders in interface UpgradeRequestname - the header namepublic String getHost()
UpgradeRequestgetHost in interface UpgradeRequestpublic HttpServletRequest getHttpServletRequest()
Note: many features of the HttpServletRequest are invalid when upgraded, especially ones that deal with body content, streams, readers, and responses.
public String getHttpVersion()
UpgradeRequest
As of RFC6455 (December 2011) this is always
HTTP/1.1
getHttpVersion in interface UpgradeRequestpublic String getLocalAddress()
ServletRequest.getLocalAddr()public Locale getLocale()
ServletRequest.getLocale()Locale for the clientpublic Enumeration<Locale> getLocales()
ServletRequest.getLocales()public String getLocalHostName()
ServletRequest.getLocalName()public int getLocalPort()
ServletRequest.getLocalPort()public InetSocketAddress getLocalSocketAddress()
InetSocketAddress for the local socket.
Warning: this can cause a DNS lookup
public String getMethod()
UpgradeRequest
As of RFC6455 (December 2011) this is always GET
getMethod in interface UpgradeRequestpublic String getOrigin()
UpgradeRequestSee RFC6455: Section 10.2 for details.
Equivalent to UpgradeRequest.getHeader(String) passed the "Origin" header.
getOrigin in interface UpgradeRequestpublic Map<String,List<String>> getParameterMap()
UpgradeRequestgetParameterMap in interface UpgradeRequest@Deprecated public Principal getPrincipal()
getUserPrincipal() insteadpublic String getProtocolVersion()
UpgradeRequest
As of RFC6455, Jetty only supports version
13
getProtocolVersion in interface UpgradeRequestpublic String getQueryString()
UpgradeRequestgetQueryString in interface UpgradeRequestpublic String getRemoteAddress()
ServletRequest.getRemoteAddr()public String getRemoteHostName()
ServletRequest.getRemoteHost()public int getRemotePort()
ServletRequest.getRemotePort()public InetSocketAddress getRemoteSocketAddress()
InetSocketAddress for the remote socket.
Warning: this can cause a DNS lookup
public String getRequestPath()
public URI getRequestURI()
UpgradeRequestgetRequestURI in interface UpgradeRequestpublic HttpSession getSession()
Note: this is equivalent to HttpServletRequest.getSession(boolean)
and will not create a new HttpSession.
getSession in interface UpgradeRequestpublic List<String> getSubProtocols()
UpgradeRequestgetSubProtocols in interface UpgradeRequestpublic Principal getUserPrincipal()
HttpServletRequest.getUserPrincipal()getUserPrincipal in interface UpgradeRequestpublic boolean hasSubProtocol(String test)
UpgradeRequesthasSubProtocol in interface UpgradeRequesttest - the sub-protocol to test forpublic boolean isOrigin(String test)
UpgradeRequestisOrigin in interface UpgradeRequesttest - the supplied originpublic boolean isSecure()
UpgradeRequestisSecure in interface UpgradeRequestpublic boolean isUserInRole(String role)
public void setCookies(List<HttpCookie> cookies)
UpgradeRequestsetCookies in interface UpgradeRequestcookies - the cookies to usepublic void setExtensions(List<ExtensionConfig> configs)
UpgradeRequestsetExtensions in interface UpgradeRequestconfigs - the list of extension configurationspublic void setHeader(String name, List<String> values)
UpgradeRequestOverrides any previous value for this named header
setHeader in interface UpgradeRequestname - the name of the headervalues - the multi-value fieldpublic void setHeader(String name, String value)
UpgradeRequestOverrides any previous value for this named header
setHeader in interface UpgradeRequestname - the header to setvalue - the value to set it topublic void setHeaders(Map<String,List<String>> headers)
UpgradeRequestOnly 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.
setHeaders in interface UpgradeRequestheaders - the headers to setpublic void setHttpVersion(String httpVersion)
UpgradeRequest
As of RFC6455 (December 2011) this should always be
HTTP/1.1
setHttpVersion in interface UpgradeRequesthttpVersion - the HTTP version to use.public void setMethod(String method)
UpgradeRequest
As of RFC6455 (December 2011) this is always GET
setMethod in interface UpgradeRequestmethod - the HTTP method to use.public void setRequestURI(URI uri)
UpgradeRequest
Must be an absolute URI with scheme 'ws' or 'wss'
setRequestURI in interface UpgradeRequesturi - the Request URIpublic void setSession(Object session)
UpgradeRequestTypically used to associate the Servlet HttpSession object.
setSession in interface UpgradeRequestsession - the session object to associate with this requestpublic void setSubProtocols(List<String> subProtocols)
UpgradeRequestsetSubProtocols in interface UpgradeRequestsubProtocols - the offered sub-protocol listpublic void setSubProtocols(String... protocols)
UpgradeRequestsetSubProtocols in interface UpgradeRequestprotocols - the offered sub-protocol listCopyright © 2010 - 2020 Adobe. All Rights Reserved