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>
public class WebSocketHttpHeaders extends HttpHeaders
AnHttpHeadersvariant that adds support for the HTTP headers defined by the WebSocket specification RFC 6455.- Since:
- 4.0
- Author:
- Rossen Stoyanchev
- See Also:
- Serialized Form
Field Summary
Fields Modifier and Type Field Description static StringSEC_WEBSOCKET_ACCEPTstatic StringSEC_WEBSOCKET_EXTENSIONSstatic StringSEC_WEBSOCKET_KEYstatic StringSEC_WEBSOCKET_PROTOCOLstatic StringSEC_WEBSOCKET_VERSIONFields inherited from class org.springframework.http.HttpHeaders
ACCEPT, ACCEPT_CHARSET, ACCEPT_ENCODING, ACCEPT_LANGUAGE, 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, 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
Constructors Constructor Description WebSocketHttpHeaders()Create 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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(String headerName, String headerValue)Add the given, single header value under the given name.voidclear()booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<String,List<String>>>entrySet()booleanequals(Object other)List<String>get(Object key)StringgetFirst(String headerName)Return the first header value for the given header name, if any.StringgetSecWebSocketAccept()Returns the value of theSec-WebSocket-Acceptheader.List<WebSocketExtension>getSecWebSocketExtensions()Returns the value of theSec-WebSocket-Extensionsheader.StringgetSecWebSocketKey()Returns the value of theSec-WebSocket-Keyheader.List<String>getSecWebSocketProtocol()Returns the value of theSec-WebSocket-Keyheader.StringgetSecWebSocketVersion()Returns the value of theSec-WebSocket-Versionheader.inthashCode()booleanisEmpty()Set<String>keySet()List<String>put(String key, List<String> value)voidputAll(Map<? extends String,? extends List<String>> m)static WebSocketHttpHeadersreadOnlyWebSocketHttpHeaders(WebSocketHttpHeaders headers)ReturnsWebSocketHttpHeadersobject that can only be read, not written to.List<String>remove(Object key)voidset(String headerName, String headerValue)Set the given, single header value under the given name.voidsetAll(Map<String,String> values)Set the given values under.voidsetSecWebSocketAccept(String secWebSocketAccept)Sets the (new) value of theSec-WebSocket-Acceptheader.voidsetSecWebSocketExtensions(List<WebSocketExtension> extensions)Sets the (new) value(s) of theSec-WebSocket-Extensionsheader.voidsetSecWebSocketKey(String secWebSocketKey)Sets the (new) value of theSec-WebSocket-Keyheader.voidsetSecWebSocketProtocol(String secWebSocketProtocol)Sets the (new) value of theSec-WebSocket-Protocolheader.voidsetSecWebSocketProtocol(List<String> secWebSocketProtocols)Sets the (new) value of theSec-WebSocket-Protocolheader.voidsetSecWebSocketVersion(String secWebSocketVersion)Sets the (new) value of theSec-WebSocket-Versionheader.intsize()Map<String,String>toSingleValueMap()Return aMapwith the first values contained in thisMultiValueMap.StringtoString()Collection<List<String>>values()Methods inherited from class org.springframework.http.HttpHeaders
getAccept, getAcceptCharset, getAccessControlAllowCredentials, getAccessControlAllowHeaders, getAccessControlAllowMethods, getAccessControlAllowOrigin, getAccessControlExposeHeaders, getAccessControlMaxAge, getAccessControlRequestHeaders, getAccessControlRequestMethod, getAllow, getCacheControl, getConnection, getContentLength, getContentType, getDate, getETag, getETagValuesAsList, getExpires, getFieldValues, getFirstDate, getIfMatch, getIfModifiedSince, getIfNoneMatch, getIfUnmodifiedSince, getLastModified, getLocation, getOrigin, getPragma, getRange, getUpgrade, getValuesAsList, getVary, readOnlyHttpHeaders, setAccept, setAcceptCharset, setAccessControlAllowCredentials, setAccessControlAllowHeaders, setAccessControlAllowMethods, setAccessControlAllowOrigin, setAccessControlExposeHeaders, setAccessControlMaxAge, setAccessControlRequestHeaders, setAccessControlRequestMethod, setAllow, setCacheControl, setConnection, setConnection, setContentDispositionFormData, setContentDispositionFormData, setContentLength, setContentType, setDate, setDate, setETag, setExpires, setIfMatch, setIfMatch, setIfModifiedSince, setIfNoneMatch, setIfNoneMatch, setIfUnmodifiedSince, setLastModified, setLocation, setOrigin, setPragma, setRange, setUpgrade, setVary, 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, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
Field Detail
SEC_WEBSOCKET_ACCEPT
public static final String SEC_WEBSOCKET_ACCEPT
- See Also:
- Constant Field Values
SEC_WEBSOCKET_EXTENSIONS
public static final String SEC_WEBSOCKET_EXTENSIONS
- See Also:
- Constant Field Values
SEC_WEBSOCKET_KEY
public static final String SEC_WEBSOCKET_KEY
- See Also:
- Constant Field Values
SEC_WEBSOCKET_PROTOCOL
public static final String SEC_WEBSOCKET_PROTOCOL
- See Also:
- Constant Field Values
SEC_WEBSOCKET_VERSION
public static final String SEC_WEBSOCKET_VERSION
- See Also:
- Constant Field Values
Constructor Detail
WebSocketHttpHeaders
public WebSocketHttpHeaders()
Create a new instance.
WebSocketHttpHeaders
public WebSocketHttpHeaders(HttpHeaders headers)
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 Detail
readOnlyWebSocketHttpHeaders
public static WebSocketHttpHeaders readOnlyWebSocketHttpHeaders(WebSocketHttpHeaders headers)
ReturnsWebSocketHttpHeadersobject that can only be read, not written to.
setSecWebSocketAccept
public void setSecWebSocketAccept(String secWebSocketAccept)
Sets the (new) value of theSec-WebSocket-Acceptheader.- Parameters:
secWebSocketAccept- the value of the header
getSecWebSocketAccept
public String getSecWebSocketAccept()
Returns the value of theSec-WebSocket-Acceptheader.- Returns:
- the value of the header
getSecWebSocketExtensions
public List<WebSocketExtension> getSecWebSocketExtensions()
Returns the value of theSec-WebSocket-Extensionsheader.- Returns:
- the value of the header
setSecWebSocketExtensions
public void setSecWebSocketExtensions(List<WebSocketExtension> extensions)
Sets the (new) value(s) of theSec-WebSocket-Extensionsheader.- Parameters:
extensions- the values for the header
setSecWebSocketKey
public void setSecWebSocketKey(String secWebSocketKey)
Sets the (new) value of theSec-WebSocket-Keyheader.- Parameters:
secWebSocketKey- the value of the header
getSecWebSocketKey
public String getSecWebSocketKey()
Returns the value of theSec-WebSocket-Keyheader.- Returns:
- the value of the header
setSecWebSocketProtocol
public void setSecWebSocketProtocol(String secWebSocketProtocol)
Sets the (new) value of theSec-WebSocket-Protocolheader.- Parameters:
secWebSocketProtocol- the value of the header
setSecWebSocketProtocol
public void setSecWebSocketProtocol(List<String> secWebSocketProtocols)
Sets the (new) value of theSec-WebSocket-Protocolheader.- Parameters:
secWebSocketProtocols- the value of the header
getSecWebSocketProtocol
public List<String> getSecWebSocketProtocol()
Returns the value of theSec-WebSocket-Keyheader.- Returns:
- the value of the header
setSecWebSocketVersion
public void setSecWebSocketVersion(String secWebSocketVersion)
Sets the (new) value of theSec-WebSocket-Versionheader.- Parameters:
secWebSocketVersion- the value of the header
getSecWebSocketVersion
public String getSecWebSocketVersion()
Returns the value of theSec-WebSocket-Versionheader.- Returns:
- the value of the header
getFirst
public String getFirst(String headerName)
Return the first header value for the given header name, if any.- Specified by:
getFirstin interfaceMultiValueMap<String,String>- Overrides:
getFirstin classHttpHeaders- Parameters:
headerName- the header name- Returns:
- the first header value; or
null
add
public void add(String headerName, String headerValue)
Add the given, single header value under the given name.- Specified by:
addin interfaceMultiValueMap<String,String>- Overrides:
addin classHttpHeaders- Parameters:
headerName- the header nameheaderValue- the header value- Throws:
UnsupportedOperationException- if adding headers is not supported- See Also:
put(String, List),set(String, String)
set
public void set(String headerName, String headerValue)
Set the given, single header value under the given name.- Specified by:
setin interfaceMultiValueMap<String,String>- Overrides:
setin classHttpHeaders- Parameters:
headerName- the header nameheaderValue- the header value- Throws:
UnsupportedOperationException- if adding headers is not supported- See Also:
put(String, List),add(String, String)
setAll
public void setAll(Map<String,String> values)
Description copied from interface:MultiValueMapSet the given values under.- Specified by:
setAllin interfaceMultiValueMap<String,String>- Overrides:
setAllin classHttpHeaders- Parameters:
values- the values.
toSingleValueMap
public Map<String,String> toSingleValueMap()
Description copied from interface:MultiValueMapReturn aMapwith the first values contained in thisMultiValueMap.- Specified by:
toSingleValueMapin interfaceMultiValueMap<String,String>- Overrides:
toSingleValueMapin classHttpHeaders- Returns:
- a single value representation of this map
size
public int size()
isEmpty
public boolean isEmpty()
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKeyin interfaceMap<String,List<String>>- Overrides:
containsKeyin classHttpHeaders
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<String,List<String>>- Overrides:
containsValuein classHttpHeaders
clear
public void clear()
values
public Collection<List<String>> values()
hashCode
public int hashCode()
toString
public String toString()
- Overrides:
toStringin classHttpHeaders