Class WebSocketHttpHeaders
- All Implemented Interfaces:
- Serializable
HttpHeaders variant that adds support for
 the HTTP headers defined by the WebSocket specification RFC 6455.- Since:
- 4.0
- Author:
- Rossen Stoyanchev
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final StringFields inherited from class org.springframework.http.HttpHeadersACCEPT, 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 SummaryConstructorsConstructorDescriptionCreate a new instance.WebSocketHttpHeaders(HttpHeaders headers) Create an instance that wraps the given pre-existing HttpHeaders and also propagate all changes to it.
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdd the given, single header value under the given name.voidclear()Remove all headers from this HttpHeaders instance.booleancontainsHeader(String key) Returnstrueif this HttpHeaders contains an entry for the given header name.booleanvoidforEach(BiConsumer<? super String, ? super List<String>> action) Perform an action over each header, as when iterated viaHttpHeaders.headerSet().Get the list of values associated with the given header name, or null.Return the first header value for the given header name, if any.Returns the value of theSec-WebSocket-Acceptheader.Returns the value of theSec-WebSocket-Extensionsheader.Returns the value of theSec-WebSocket-Keyheader.Returns the value of theSec-WebSocket-Protocolheader.Returns the value of theSec-WebSocket-Versionheader.inthashCode()Return the set of header names.Return a view of the headers as an entrySetof key-list pairs.booleanisEmpty()Returnstrueif this HttpHeaders contains no header entry.Set the list of values associated with the given header name.voidPut all the entries from the givenMultiValueMapinto this HttpHeaders.voidputAll(HttpHeaders headers) Put all the entries from the given HttpHeaders into this HttpHeaders.putIfAbsent(String headerName, List<String> headerValues) Set header values for the given header name if that header name isn't already present in this HttpHeaders and returnnull.Remove a header from this HttpHeaders instance, and return the associated value list ornullif that header wasn't present.voidSet the given, single header value under the given name.voidSet all single header value from the given Map under each of their corresponding name.voidsetSecWebSocketAccept(@Nullable String secWebSocketAccept) Sets the (new) value of theSec-WebSocket-Acceptheader.voidsetSecWebSocketExtensions(List<WebSocketExtension> extensions) Sets the (new) value(s) of theSec-WebSocket-Extensionsheader.voidsetSecWebSocketKey(@Nullable 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(@Nullable String secWebSocketVersion) Sets the (new) value of theSec-WebSocket-Versionheader.intsize()Return the number of headers in the collection.Return this HttpHeaders as aMapwith the first values for each header name.toString()Methods inherited from class org.springframework.http.HttpHeadersaddAll, addAll, asMultiValueMap, asSingleValueMap, clearContentHeaders, containsHeaderValue, copyOf, copyOf, 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, getOrDefault, getOrEmpty, getOrigin, getPragma, getRange, getUpgrade, getValuesAsList, getVary, hasHeaderValues, 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
- 
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- 
WebSocketHttpHeaderspublic WebSocketHttpHeaders()Create a new instance.
- 
WebSocketHttpHeadersCreate 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- 
setSecWebSocketAcceptSets the (new) value of theSec-WebSocket-Acceptheader.- Parameters:
- secWebSocketAccept- the value of the header
 
- 
getSecWebSocketAcceptReturns the value of theSec-WebSocket-Acceptheader.- Returns:
- the value of the header
 
- 
getSecWebSocketExtensionsReturns the value of theSec-WebSocket-Extensionsheader.- Returns:
- the value of the header
 
- 
setSecWebSocketExtensionsSets the (new) value(s) of theSec-WebSocket-Extensionsheader.- Parameters:
- extensions- the values for the header
 
- 
setSecWebSocketKeySets the (new) value of theSec-WebSocket-Keyheader.- Parameters:
- secWebSocketKey- the value of the header
 
- 
getSecWebSocketKeyReturns the value of theSec-WebSocket-Keyheader.- Returns:
- the value of the header
 
- 
setSecWebSocketProtocolSets the (new) value of theSec-WebSocket-Protocolheader.- Parameters:
- secWebSocketProtocol- the value of the header
 
- 
setSecWebSocketProtocolSets the (new) value of theSec-WebSocket-Protocolheader.- Parameters:
- secWebSocketProtocols- the value of the header
 
- 
getSecWebSocketProtocolReturns the value of theSec-WebSocket-Protocolheader.- Returns:
- the value of the header
 
- 
setSecWebSocketVersionSets the (new) value of theSec-WebSocket-Versionheader.- Parameters:
- secWebSocketVersion- the value of the header
 
- 
getSecWebSocketVersionReturns the value of theSec-WebSocket-Versionheader.- Returns:
- the value of the header
 
- 
getFirstReturn the first header value for the given header name, if any.- Overrides:
- getFirstin class- HttpHeaders
- Parameters:
- headerName- the header name
- Returns:
- the first header value; or null
 
- 
addAdd the given, single header value under the given name.- Overrides:
- addin class- HttpHeaders
- Parameters:
- headerName- the header name
- headerValue- the header value
- Throws:
- UnsupportedOperationException- if adding headers is not supported
- See Also:
 
- 
setSet the given, single header value under the given name.- Overrides:
- setin class- HttpHeaders
- Parameters:
- headerName- the header name
- headerValue- the header value
- Throws:
- UnsupportedOperationException- if adding headers is not supported
- See Also:
 
- 
setAllDescription copied from class:HttpHeadersSet all single header value from the given Map under each of their corresponding name.- Overrides:
- setAllin class- HttpHeaders
- Parameters:
- values- the name-single-value pairs
- See Also:
 
- 
toSingleValueMapDescription copied from class:HttpHeadersReturn this HttpHeaders as aMapwith the first values for each header name.The difference between this method and HttpHeaders.asSingleValueMap()is that this method returns a copy of the headers, whereas the latter returns a view. This copy also ensures that collection-iterating methods likeentrySet()are case-insensitive.- Overrides:
- toSingleValueMapin class- HttpHeaders
- Returns:
- a single value representation of these headers
 
- 
sizepublic int size()Description copied from class:HttpHeadersReturn the number of headers in the collection. This can be inflated, seeclass level javadoc.- Overrides:
- sizein class- HttpHeaders
 
- 
isEmptypublic boolean isEmpty()Description copied from class:HttpHeadersReturnstrueif this HttpHeaders contains no header entry.- Overrides:
- isEmptyin class- HttpHeaders
 
- 
containsHeaderDescription copied from class:HttpHeadersReturnstrueif this HttpHeaders contains an entry for the given header name.- Overrides:
- containsHeaderin class- HttpHeaders
- Parameters:
- key- the header name
 
- 
getDescription copied from class:HttpHeadersGet the list of values associated with the given header name, or null.To ensure support for double-quoted values, see also HttpHeaders.getValuesAsList(String).- Overrides:
- getin class- HttpHeaders
- Parameters:
- headerName- the header name
- See Also:
 
- 
putDescription copied from class:HttpHeadersSet the list of values associated with the given header name. Returns the previous list of values, ornullif the header was not present.- Overrides:
- putin class- HttpHeaders
- Parameters:
- key- the header name
- value- the new values
- Returns:
- the old values for the given header name
 
- 
removeDescription copied from class:HttpHeadersRemove a header from this HttpHeaders instance, and return the associated value list ornullif that header wasn't present.- Overrides:
- removein class- HttpHeaders
- Parameters:
- key- the name of the header to remove
- Returns:
- the value list associated with the removed header name
 
- 
putAllDescription copied from class:HttpHeadersPut all the entries from the given HttpHeaders into this HttpHeaders.- Overrides:
- putAllin class- HttpHeaders
- Parameters:
- headers- the given headers
- See Also:
 
- 
putAllDescription copied from class:HttpHeadersPut all the entries from the givenMultiValueMapinto this HttpHeaders.- Overrides:
- putAllin class- HttpHeaders
- Parameters:
- m- the given headers
- See Also:
 
- 
clearpublic void clear()Description copied from class:HttpHeadersRemove all headers from this HttpHeaders instance.- Overrides:
- clearin class- HttpHeaders
 
- 
headerNamesDescription copied from class:HttpHeadersReturn the set of header names. BothSet.remove(Object)andSet.clear()operations are supported and mutate the headers.This collection is guaranteed to contain only one casing variant of each header name even if the backing structure stores multiple casing variants of names. The first encountered variant is the one that is retained. - Overrides:
- headerNamesin class- HttpHeaders
- Returns:
- a Setof all the headers names
 
- 
headerSetDescription copied from class:HttpHeadersReturn a view of the headers as an entrySetof key-list pairs. BothIterator.remove()andMap.Entry.setValue(V)are supported and mutate the headers.This collection is guaranteed to contain one entry per header name even if the backing structure stores multiple casing variants of names, at the cost of first copying the names into a case-insensitive set for filtering the iteration. - Overrides:
- headerSetin class- HttpHeaders
- Returns:
- a Setview that iterates over all headers in a case-insensitive manner
 
- 
forEachDescription copied from class:HttpHeadersPerform an action over each header, as when iterated viaHttpHeaders.headerSet().- Overrides:
- forEachin class- HttpHeaders
- Parameters:
- action- the action to be performed for each entry
 
- 
putIfAbsentDescription copied from class:HttpHeadersSet header values for the given header name if that header name isn't already present in this HttpHeaders and returnnull. If the header is already present, returns the associated value list instead.- Overrides:
- putIfAbsentin class- HttpHeaders
- Parameters:
- headerName- the header name
- headerValues- the header values to set if header is not present
- Returns:
- the previous value or null
 
- 
equals- Overrides:
- equalsin class- HttpHeaders
 
- 
hashCodepublic int hashCode()- Overrides:
- hashCodein class- HttpHeaders
 
- 
toString- Overrides:
- toStringin class- HttpHeaders
 
 
-