Top Description Fields Constructors Methods
org.eclipse.jetty.websocket.client

public final Class ClientUpgradeRequest

extends Object
implements UpgradeRequest
Class Inheritance
All Implemented Interfaces
org.eclipse.jetty.websocket.api.UpgradeRequest
Imports
java.net.HttpCookie, .URI, java.security.Principal, java.util.ArrayList, .Collections, .List, .Map, .Objects, .TreeMap, java.util.concurrent.TimeUnit, org.eclipse.jetty.http.HttpHeader, .HttpScheme, org.eclipse.jetty.websocket.api.ExtensionConfig, .UpgradeRequest, .UpgradeResponse

Client based UpgradeRequest API

Field Summary

Modifier and TypeField and Description
public static final String
ABNF_REQUIRED_QUOTING

ABNF from RFC 2616, RFC 822, and RFC 6455 specified characters requiring quoting.

private final List<HttpCookie>
private final List<ExtensionConfig>
private final Map<String, List<String>>
private final String
private final URI
private final List<String>
private long

Constructor Summary

AccessConstructor and Description
public
public
ClientUpgradeRequest(URI uri)
Deprecated use ClientUpgradeRequest() instead.

Method Summary

Modifier and TypeMethod and Description
public void
addExtensions(ExtensionConfig...
the configuration(s) to add
configs
)

Add WebSocket Extension Configuration(s) to Upgrade Request.

public void
addExtensions(String...
the configuration(s) to add
configs
)

Add WebSocket Extension Configuration(s) to request

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

public List<HttpCookie>
getCookies()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getCookies.

Get the list of Cookies on the Upgrade request

public List<ExtensionConfig>
getExtensions()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getExtensions.

Get the list of WebSocket Extension Configurations for this Upgrade Request.

public String
getHeader(String
the name of the header
name
)

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getHeader.

Get a specific Header value from Upgrade Request

public int
getHeaderInt(String
the name of the header
name
)

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getHeaderInt.

Get the specific Header value, as an int, from the Upgrade Request.

public Map<String, List<String>>
getHeaders()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getHeaders.

Get the headers as a Map of keys to value lists.

public List<String>
getHeaders(String
the header name
name
)

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getHeaders.

Get the specific header values (for multi-value headers)

public String
getHost()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getHost.

The host of the Upgrade Request URI

public String
getHttpVersion()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getHttpVersion.

The HTTP version used for this Upgrade Request

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

public String
getMethod()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getMethod.

The HTTP method for this Upgrade Request.

public String
getOrigin()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getOrigin.

The WebSocket Origin of this Upgrade Request

See RFC6455: Section 10.2 for details.

public Map<String, List<String>>
getParameterMap()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getParameterMap.

Returns a map of the query parameters of the request.

public String
getProtocolVersion()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getProtocolVersion.

Get the WebSocket Protocol Version

As of RFC6455, Jetty only supports version 13

public String
getQueryString()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getQueryString.

Get the Query String of the request URI.

public URI
public List<String>
getSubProtocols()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getSubProtocols.

Get the list of offered WebSocket sub-protocols.

public long
getTimeout()

Returns: the total timeout for this request, in milliseconds; zero or negative if the timeout is disabled

public Principal
getUserPrincipal()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getUserPrincipal.

Get the User Principal for this request.

public boolean
hasSubProtocol(String
the sub-protocol to test for
test
)

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.hasSubProtocol.

Test if a specific sub-protocol is offered

public boolean
isSecure()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.isSecure.

Test if connection is secure.

public static String
private static void
quoteIfNeeded(StringBuilder
the buffer to append to
buf
,
String
the string to possibly quote
str
,
String
the delimiter characters that will trigger automatic quoting
delim
)

Append into buf the provided string, adding quotes if needed.

public void
setCookies(List<HttpCookie>
the cookies to use
cookies
)

Set the list of Cookies on the request

public void
setExtensions(List<ExtensionConfig>
the list of extension configurations
configs
)

Set the list of WebSocket Extension configurations on the request.

public void
setHeader(String
the name of the header
name
,
List<String>
the multi-value field
values
)

Set a specific header with multi-value field

Overrides any previous value for this named header

public void
setHeader(String
the header to set
name
,
String
the value to set it to
value
)

Set a specific header value

Overrides any previous value for this named header

public void
setHeaders(Map<String, List<String>>
the headers to set
headers
)

Sets multiple headers on the request.

public void
setSubProtocols(List<String>
the offered sub-protocol list
protocols
)

Set the offered WebSocket Sub-Protocol list.

public void
setSubProtocols(String...
the offered sub-protocol list
protocols
)

Set the offered WebSocket Sub-Protocol list.

public void
setTimeout(long
the total timeout for the request/response conversation of the WebSocket handshake; use zero or a negative value to disable the timeout
timeout
,
TimeUnit
the timeout unit
unit
)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ABNF_REQUIRED_QUOTINGback to summary
public static final String ABNF_REQUIRED_QUOTING

ABNF from RFC 2616, RFC 822, and RFC 6455 specified characters requiring quoting.

cookiesback to summary
private final List<HttpCookie> cookies
extensionsback to summary
private final List<ExtensionConfig> extensions
headersback to summary
private final Map<String, List<String>> headers
hostback to summary
private final String host
requestURIback to summary
private final URI requestURI
subProtocolsback to summary
private final List<String> subProtocols
timeoutback to summary
private long timeout

Constructor Detail

ClientUpgradeRequestback to summary
public ClientUpgradeRequest()
ClientUpgradeRequestback to summary
public ClientUpgradeRequest(URI uri)

Deprecated

use ClientUpgradeRequest() instead.

Annotations
@Deprecated

Method Detail

addExtensionsback to summary
public void addExtensions(ExtensionConfig... configs)

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:ExtensionConfig[]

the configuration(s) to add

addExtensionsback to summary
public void addExtensions(String... configs)

Add WebSocket Extension Configuration(s) to request

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

Parameters
configs:String[]

the configuration(s) to add

getCookiesback to summary
public List<HttpCookie> getCookies()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getCookies.

Doc from org.eclipse.jetty.websocket.api.UpgradeRequest.getCookies.

Get the list of Cookies on the Upgrade request

Returns:List<HttpCookie>

the list of Cookies

Annotations
@Override
getExtensionsback to summary
public List<ExtensionConfig> getExtensions()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getExtensions.

Doc from org.eclipse.jetty.websocket.api.UpgradeRequest.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:List<ExtensionConfig>

the list of Extension configurations (in the order they were specified)

Annotations
@Override
getHeaderback to summary
public String getHeader(String name)

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getHeader.

Doc from org.eclipse.jetty.websocket.api.UpgradeRequest.getHeader.

Get a specific Header value from Upgrade Request

Parameters
name:String

the name of the header

Returns:String

the value of the header (null if header does not exist)

Annotations
@Override
getHeaderIntback to summary
public int getHeaderInt(String name)

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getHeaderInt.

Doc from org.eclipse.jetty.websocket.api.UpgradeRequest.getHeaderInt.

Get the specific Header value, as an int, from the Upgrade Request.

Parameters
name:String

the name of the header

Returns:int

the value of the header as an int (-1 if header does not exist)

Annotations
@Override
getHeadersback to summary
public Map<String, List<String>> getHeaders()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getHeaders.

Doc from org.eclipse.jetty.websocket.api.UpgradeRequest.getHeaders.

Get the headers as a Map of keys to value lists.

Returns:Map<String, List<String>>

the headers

Annotations
@Override
getHeadersback to summary
public List<String> getHeaders(String name)

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getHeaders.

Doc from org.eclipse.jetty.websocket.api.UpgradeRequest.getHeaders.

Get the specific header values (for multi-value headers)

Parameters
name:String

the header name

Returns:List<String>

the value list (null if no header exists)

Annotations
@Override
getHostback to summary
public String getHost()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getHost.

Doc from org.eclipse.jetty.websocket.api.UpgradeRequest.getHost.

The host of the Upgrade Request URI

Returns:String

host of the request URI

Annotations
@Override
getHttpVersionback to summary
public String getHttpVersion()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getHttpVersion.

Doc from org.eclipse.jetty.websocket.api.UpgradeRequest.getHttpVersion.

The HTTP version used for this Upgrade Request

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

Returns:String

the HTTP Version used

Annotations
@Override
getMethodback to summary
public String getMethod()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getMethod.

Doc from org.eclipse.jetty.websocket.api.UpgradeRequest.getMethod.

The HTTP method for this Upgrade Request.

As of RFC6455 (December 2011) this is always GET

Returns:String

the HTTP method used

Annotations
@Override
getOriginback to summary
public String getOrigin()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getOrigin.

Doc from org.eclipse.jetty.websocket.api.UpgradeRequest.getOrigin.

The WebSocket Origin of this Upgrade Request

See RFC6455: Section 10.2 for details.

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

Returns:String

the Origin header

Annotations
@Override
getParameterMapback to summary
public Map<String, List<String>> getParameterMap()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getParameterMap.

Doc from org.eclipse.jetty.websocket.api.UpgradeRequest.getParameterMap.

Returns a map of the query parameters of the request.

Returns:Map<String, List<String>>

a unmodifiable map of query parameters of the request.

Annotations
@Override
getProtocolVersionback to summary
public String getProtocolVersion()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getProtocolVersion.

Doc from org.eclipse.jetty.websocket.api.UpgradeRequest.getProtocolVersion.

Get the WebSocket Protocol Version

As of RFC6455, Jetty only supports version 13

Returns:String

the WebSocket protocol version

Annotations
@Override
getQueryStringback to summary
public String getQueryString()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getQueryString.

Doc from org.eclipse.jetty.websocket.api.UpgradeRequest.getQueryString.

Get the Query String of the request URI.

Returns:String

the request uri query string

Annotations
@Override
getRequestURIback to summary
public URI getRequestURI()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getRequestURI.

Doc from org.eclipse.jetty.websocket.api.UpgradeRequest.getRequestURI.

Get the Request URI

Returns:URI

the request URI

Annotations
@Override
getSubProtocolsback to summary
public List<String> getSubProtocols()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getSubProtocols.

Doc from org.eclipse.jetty.websocket.api.UpgradeRequest.getSubProtocols.

Get the list of offered WebSocket sub-protocols.

Returns:List<String>

the list of offered sub-protocols

Annotations
@Override
getTimeoutback to summary
public long getTimeout()
Returns:long

the total timeout for this request, in milliseconds; zero or negative if the timeout is disabled

getUserPrincipalback to summary
public Principal getUserPrincipal()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.getUserPrincipal.

Doc from org.eclipse.jetty.websocket.api.UpgradeRequest.getUserPrincipal.

Get the User Principal for this request.

Only applicable when using UpgradeRequest from server side.

Returns:Principal

the user principal

Annotations
@Override
hasSubProtocolback to summary
public boolean hasSubProtocol(String test)

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.hasSubProtocol.

Doc from org.eclipse.jetty.websocket.api.UpgradeRequest.hasSubProtocol.

Test if a specific sub-protocol is offered

Parameters
test:String

the sub-protocol to test for

Returns:boolean

true if sub-protocol exists on request

Annotations
@Override
isSecureback to summary
public boolean isSecure()

Implements org.eclipse.jetty.websocket.api.UpgradeRequest.isSecure.

Doc from org.eclipse.jetty.websocket.api.UpgradeRequest.isSecure.

Test if connection is secure.

Returns:boolean

true if connection is secure.

Annotations
@Override
joinValuesback to summary
public static String joinValues(List<String> values)
quoteIfNeededback to summary
private static void quoteIfNeeded(StringBuilder buf, String str, String delim)

Append into buf the provided string, adding quotes if needed.

Quoting is determined if any of the characters in the delim are found in the input str.

Parameters
buf:StringBuilder

the buffer to append to

str:String

the string to possibly quote

delim:String

the delimiter characters that will trigger automatic quoting

setCookiesback to summary
public void setCookies(List<HttpCookie> cookies)

Set the list of Cookies on the request

Parameters
cookies:List<HttpCookie>

the cookies to use

setExtensionsback to summary
public void setExtensions(List<ExtensionConfig> configs)

Set the list of WebSocket Extension configurations on the request.

Parameters
configs:List<ExtensionConfig>

the list of extension configurations

setHeaderback to summary
public void setHeader(String name, List<String> values)

Set a specific header with multi-value field

Overrides any previous value for this named header

Parameters
name:String

the name of the header

values:List<String>

the multi-value field

setHeaderback to summary
public void setHeader(String name, String value)

Set a specific header value

Overrides any previous value for this named header

Parameters
name:String

the header to set

value:String

the value to set it to

setHeadersback to summary
public void setHeaders(Map<String, List<String>> headers)

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:Map<String, List<String>>

the headers to set

setSubProtocolsback to summary
public void setSubProtocols(List<String> protocols)

Set the offered WebSocket Sub-Protocol list.

Parameters
protocols:List<String>

the offered sub-protocol list

setSubProtocolsback to summary
public void setSubProtocols(String... protocols)

Set the offered WebSocket Sub-Protocol list.

Parameters
protocols:String[]

the offered sub-protocol list

setTimeoutback to summary
public void setTimeout(long timeout, TimeUnit unit)
Parameters
timeout:long

the total timeout for the request/response conversation of the WebSocket handshake; use zero or a negative value to disable the timeout

unit:TimeUnit

the timeout unit