Package org.springframework.web.socket
Class WebSocketHttpHeaders
java.lang.Object
org.springframework.http.HttpHeaders
org.springframework.web.socket.WebSocketHttpHeaders
- All Implemented Interfaces:
Serializable
,Map<String,
,List<String>> MultiValueMap<String,
String>
An
HttpHeaders
variant that adds support for
the HTTP headers defined by the WebSocket specification RFC 6455.- Since:
- 4.0
- Author:
- Rossen Stoyanchev
- See Also:
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
Fields inherited from class org.springframework.http.HttpHeaders
ACCEPT, ACCEPT_CHARSET, ACCEPT_ENCODING, ACCEPT_LANGUAGE, ACCEPT_PATCH, ACCEPT_RANGES, ACCESS_CONTROL_ALLOW_CREDENTIALS, ACCESS_CONTROL_ALLOW_HEADERS, ACCESS_CONTROL_ALLOW_METHODS, ACCESS_CONTROL_ALLOW_ORIGIN, ACCESS_CONTROL_EXPOSE_HEADERS, ACCESS_CONTROL_MAX_AGE, ACCESS_CONTROL_REQUEST_HEADERS, ACCESS_CONTROL_REQUEST_METHOD, AGE, ALLOW, AUTHORIZATION, CACHE_CONTROL, CONNECTION, CONTENT_DISPOSITION, CONTENT_ENCODING, CONTENT_LANGUAGE, CONTENT_LENGTH, CONTENT_LOCATION, CONTENT_RANGE, CONTENT_TYPE, COOKIE, DATE, EMPTY, ETAG, EXPECT, EXPIRES, FROM, HOST, IF_MATCH, IF_MODIFIED_SINCE, IF_NONE_MATCH, IF_RANGE, IF_UNMODIFIED_SINCE, LAST_MODIFIED, LINK, LOCATION, MAX_FORWARDS, ORIGIN, PRAGMA, PROXY_AUTHENTICATE, PROXY_AUTHORIZATION, RANGE, REFERER, RETRY_AFTER, SERVER, SET_COOKIE, SET_COOKIE2, TE, TRAILER, TRANSFER_ENCODING, UPGRADE, USER_AGENT, VARY, VIA, WARNING, WWW_AUTHENTICATE
-
Constructor Summary
ConstructorDescriptionCreate a new instance.WebSocketHttpHeaders
(HttpHeaders headers) Create an instance that wraps the given pre-existing HttpHeaders and also propagate all changes to it. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add the given, single header value under the given name.void
clear()
boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
Return aSet
views of header entries, reconstructed from iterating over theHttpHeaders.keySet()
.boolean
void
forEach
(BiConsumer<? super String, ? super List<String>> action) Perform an action over each header, as when iterated viaHttpHeaders.entrySet()
.Return the first header value for the given header name, if any.Returns the value of theSec-WebSocket-Accept
header.Returns the value of theSec-WebSocket-Extensions
header.Returns the value of theSec-WebSocket-Key
header.Returns the value of theSec-WebSocket-Key
header.Returns the value of theSec-WebSocket-Version
header.int
hashCode()
boolean
isEmpty()
keySet()
Return aSet
view of header names.void
putIfAbsent
(String key, List<String> value) void
Set the given, single header value under the given name.void
Set the given values under.void
setSecWebSocketAccept
(@Nullable String secWebSocketAccept) Sets the (new) value of theSec-WebSocket-Accept
header.void
setSecWebSocketExtensions
(List<WebSocketExtension> extensions) Sets the (new) value(s) of theSec-WebSocket-Extensions
header.void
setSecWebSocketKey
(@Nullable String secWebSocketKey) Sets the (new) value of theSec-WebSocket-Key
header.void
setSecWebSocketProtocol
(String secWebSocketProtocol) Sets the (new) value of theSec-WebSocket-Protocol
header.void
setSecWebSocketProtocol
(List<String> secWebSocketProtocols) Sets the (new) value of theSec-WebSocket-Protocol
header.void
setSecWebSocketVersion
(@Nullable String secWebSocketVersion) Sets the (new) value of theSec-WebSocket-Version
header.int
size()
Return the number of headers in the collection.Return aMap
with the first values contained in thisMultiValueMap
.toString()
values()
Return aCollection
view of all the header values, reconstructed from iterating over theHttpHeaders.keySet()
.Methods inherited from class org.springframework.http.HttpHeaders
addAll, addAll, asSingleValueMap, clearContentHeaders, encodeBasicAuth, formatHeaders, getAccept, getAcceptCharset, getAcceptLanguage, getAcceptLanguageAsLocales, getAcceptPatch, getAccessControlAllowCredentials, getAccessControlAllowHeaders, getAccessControlAllowMethods, getAccessControlAllowOrigin, getAccessControlExposeHeaders, getAccessControlMaxAge, getAccessControlRequestHeaders, getAccessControlRequestMethod, getAllow, getCacheControl, getConnection, getContentDisposition, getContentLanguage, getContentLength, getContentType, getDate, getETag, getETagValuesAsList, getExpires, getFieldValues, getFirstDate, getFirstZonedDateTime, getHost, getIfMatch, getIfModifiedSince, getIfNoneMatch, getIfUnmodifiedSince, getLastModified, getLocation, getOrEmpty, getOrigin, getPragma, getRange, getUpgrade, getValuesAsList, getVary, headerSet, readOnlyHttpHeaders, readOnlyHttpHeaders, setAccept, setAcceptCharset, setAcceptLanguage, setAcceptLanguageAsLocales, setAcceptPatch, setAccessControlAllowCredentials, setAccessControlAllowHeaders, setAccessControlAllowMethods, setAccessControlAllowOrigin, setAccessControlExposeHeaders, setAccessControlMaxAge, setAccessControlMaxAge, setAccessControlRequestHeaders, setAccessControlRequestMethod, setAllow, setBasicAuth, setBasicAuth, setBasicAuth, setBearerAuth, setCacheControl, setCacheControl, setConnection, setConnection, setContentDisposition, setContentDispositionFormData, setContentLanguage, setContentLength, setContentType, setDate, setDate, setDate, setDate, setETag, setExpires, setExpires, setExpires, setHost, setIfMatch, setIfMatch, setIfModifiedSince, setIfModifiedSince, setIfModifiedSince, setIfNoneMatch, setIfNoneMatch, setIfUnmodifiedSince, setIfUnmodifiedSince, setIfUnmodifiedSince, setInstant, setLastModified, setLastModified, setLastModified, setLocation, setOrigin, setPragma, setRange, setUpgrade, setVary, setZonedDateTime, toCommaDelimitedString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, getOrDefault, merge, remove, replace, replace, replaceAll
Methods inherited from interface org.springframework.util.MultiValueMap
addIfAbsent
-
Field Details
-
SEC_WEBSOCKET_ACCEPT
- See Also:
-
SEC_WEBSOCKET_EXTENSIONS
- See Also:
-
SEC_WEBSOCKET_KEY
- See Also:
-
SEC_WEBSOCKET_PROTOCOL
- See Also:
-
SEC_WEBSOCKET_VERSION
- See Also:
-
-
Constructor Details
-
WebSocketHttpHeaders
public WebSocketHttpHeaders()Create a new instance. -
WebSocketHttpHeaders
Create an instance that wraps the given pre-existing HttpHeaders and also propagate all changes to it.- Parameters:
headers
- the HTTP headers to wrap
-
-
Method Details
-
setSecWebSocketAccept
Sets the (new) value of theSec-WebSocket-Accept
header.- Parameters:
secWebSocketAccept
- the value of the header
-
getSecWebSocketAccept
Returns the value of theSec-WebSocket-Accept
header.- Returns:
- the value of the header
-
getSecWebSocketExtensions
Returns the value of theSec-WebSocket-Extensions
header.- Returns:
- the value of the header
-
setSecWebSocketExtensions
Sets the (new) value(s) of theSec-WebSocket-Extensions
header.- Parameters:
extensions
- the values for the header
-
setSecWebSocketKey
Sets the (new) value of theSec-WebSocket-Key
header.- Parameters:
secWebSocketKey
- the value of the header
-
getSecWebSocketKey
Returns the value of theSec-WebSocket-Key
header.- Returns:
- the value of the header
-
setSecWebSocketProtocol
Sets the (new) value of theSec-WebSocket-Protocol
header.- Parameters:
secWebSocketProtocol
- the value of the header
-
setSecWebSocketProtocol
Sets the (new) value of theSec-WebSocket-Protocol
header.- Parameters:
secWebSocketProtocols
- the value of the header
-
getSecWebSocketProtocol
Returns the value of theSec-WebSocket-Key
header.- Returns:
- the value of the header
-
setSecWebSocketVersion
Sets the (new) value of theSec-WebSocket-Version
header.- Parameters:
secWebSocketVersion
- the value of the header
-
getSecWebSocketVersion
Returns the value of theSec-WebSocket-Version
header.- Returns:
- the value of the header
-
getFirst
Return the first header value for the given header name, if any.- Specified by:
getFirst
in interfaceMultiValueMap<String,
String> - Overrides:
getFirst
in classHttpHeaders
- Parameters:
headerName
- the header name- Returns:
- the first header value; or
null
-
add
Add the given, single header value under the given name.- Specified by:
add
in interfaceMultiValueMap<String,
String> - Overrides:
add
in classHttpHeaders
- Parameters:
headerName
- the header nameheaderValue
- the header value- Throws:
UnsupportedOperationException
- if adding headers is not supported- See Also:
-
set
Set the given, single header value under the given name.- Specified by:
set
in interfaceMultiValueMap<String,
String> - Overrides:
set
in classHttpHeaders
- Parameters:
headerName
- the header nameheaderValue
- the header value- Throws:
UnsupportedOperationException
- if adding headers is not supported- See Also:
-
setAll
Description copied from interface:MultiValueMap
Set the given values under.- Specified by:
setAll
in interfaceMultiValueMap<String,
String> - Overrides:
setAll
in classHttpHeaders
- Parameters:
values
- the values.
-
toSingleValueMap
Description copied from interface:MultiValueMap
Return aMap
with the first values contained in thisMultiValueMap
. The difference between this method andMultiValueMap.asSingleValueMap()
is that this method returns a copy of the entries of this map, whereas the latter returns a view.- Specified by:
toSingleValueMap
in interfaceMultiValueMap<String,
String> - Overrides:
toSingleValueMap
in classHttpHeaders
- Returns:
- a single value representation of this map
-
size
public int size()Description copied from class:HttpHeaders
Return the number of headers in the collection. This can be inflated, seeclass level javadoc
. -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<String,
List<String>> - Overrides:
containsKey
in classHttpHeaders
-
containsValue
- Specified by:
containsValue
in interfaceMap<String,
List<String>> - Overrides:
containsValue
in classHttpHeaders
-
get
-
put
-
remove
-
putAll
-
clear
public void clear() -
keySet
Description copied from class:HttpHeaders
Return aSet
view of header names. This can include multiple casing variants of a given header name, seeclass level javadoc
. -
values
Description copied from class:HttpHeaders
Return aCollection
view of all the header values, reconstructed from iterating over theHttpHeaders.keySet()
. This can include duplicates if multiple casing variants of a given header name are tracked, seeclass level javadoc
. -
entrySet
Description copied from class:HttpHeaders
Return aSet
views of header entries, reconstructed from iterating over theHttpHeaders.keySet()
. This can include duplicate entries if multiple casing variants of a given header name are tracked, seeclass level javadoc
. -
forEach
Description copied from class:HttpHeaders
Perform an action over each header, as when iterated viaHttpHeaders.entrySet()
. This can include duplicate entries if multiple casing variants of a given header name are tracked, seeclass level javadoc
. -
putIfAbsent
- Specified by:
putIfAbsent
in interfaceMap<String,
List<String>> - Overrides:
putIfAbsent
in classHttpHeaders
-
equals
-
hashCode
public int hashCode() -
toString
- Overrides:
toString
in classHttpHeaders
-