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

  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:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface java.util.Map

      `Map.Entry<K,V>`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `SEC_WEBSOCKET_ACCEPT`
    `static String` | `SEC_WEBSOCKET_EXTENSIONS`
    `static String` | `SEC_WEBSOCKET_KEY`
    `static String` | `SEC_WEBSOCKET_PROTOCOL`
    `static String` | `SEC_WEBSOCKET_VERSION`

  - ### Constructor Summary

    Constructors
    Constructor and 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 and Description
    --- | ---
    `void` | `add(String headerName, String headerValue)` Add the given, single header value under the given name.
    `void` | `clear()`
    `boolean` | `containsKey(Object key)`
    `boolean` | `containsValue(Object value)`
    `Set<Map.Entry<String,List<String>>>` | `entrySet()`
    `boolean` | `equals(Object other)`
    `List<String>` | `get(Object key)`
    `String` | `getFirst(String headerName)` Return the first header value for the given header name, if any.
    `String` | `getSecWebSocketAccept()` Returns the value of the `Sec-WebSocket-Accept` header.
    `List<WebSocketExtension>` | `getSecWebSocketExtensions()` Returns the value of the `Sec-WebSocket-Extensions` header.
    `String` | `getSecWebSocketKey()` Returns the value of the `Sec-WebSocket-Key` header.
    `List<String>` | `getSecWebSocketProtocol()` Returns the value of the `Sec-WebSocket-Key` header.
    `String` | `getSecWebSocketVersion()` Returns the value of the `Sec-WebSocket-Version` header.
    `int` | `hashCode()`
    `boolean` | `isEmpty()`
    `Set<String>` | `keySet()`
    `List<String>` | `put(String key, List<String> value)`
    `void` | `putAll(Map<? extends String,? extends List<String>> m)`
    `static WebSocketHttpHeaders` | `readOnlyWebSocketHttpHeaders(WebSocketHttpHeaders headers)` Returns `WebSocketHttpHeaders` object that can only be read, not written to.
    `List<String>` | `remove(Object key)`
    `void` | `set(String headerName, String headerValue)` Set the given, single header value under the given name.
    `void` | `setAll(Map<String,String> values)` Set the given values under.
    `void` | `setSecWebSocketAccept(String secWebSocketAccept)` Sets the (new) value of the `Sec-WebSocket-Accept` header.
    `void` | `setSecWebSocketExtensions(List<WebSocketExtension> extensions)` Sets the (new) value(s) of the `Sec-WebSocket-Extensions` header.
    `void` | `setSecWebSocketKey(String secWebSocketKey)` Sets the (new) value of the `Sec-WebSocket-Key` header.
    `void` | `setSecWebSocketProtocol(List<String> secWebSocketProtocols)` Sets the (new) value of the `Sec-WebSocket-Protocol` header.
    `void` | `setSecWebSocketProtocol(String secWebSocketProtocol)` Sets the (new) value of the `Sec-WebSocket-Protocol` header.
    `void` | `setSecWebSocketVersion(String secWebSocketVersion)` Sets the (new) value of the `Sec-WebSocket-Version` header.
    `int` | `size()`
    `Map<String,String>` | `toSingleValueMap()` Returns the first values contained in this `MultiValueMap`.
    `String` | `toString()`
    `Collection<List<String>>` | `values()`

    - ### Methods inherited from class org.springframework.http.HttpHeaders

      `getAccept, getAcceptCharset, getAllow, getCacheControl, getConnection, getContentLength, getContentType, getDate, getETag, getExpires, getFirstDate, getFirstValueAsList, getIfModifiedSince, getIfNoneMatch, getIfNotModifiedSince, getLastModified, getLocation, getOrigin, getPragma, getUpgrade, readOnlyHttpHeaders, setAccept, setAcceptCharset, setAllow, setCacheControl, setConnection, setConnection, setContentDispositionFormData, setContentLength, setContentType, setDate, setDate, setETag, setExpires, setIfModifiedSince, setIfNoneMatch, setIfNoneMatch, setLastModified, setLocation, setOrigin, setPragma, setUpgrade, 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)

      Returns `WebSocketHttpHeaders` object that can only be read, not written to.

    - #### setSecWebSocketAccept

          public void setSecWebSocketAccept(String secWebSocketAccept)

      Sets the (new) value of the `Sec-WebSocket-Accept` header.
      Parameters:
        `secWebSocketAccept` - the value of the header

    - #### getSecWebSocketAccept

          public String getSecWebSocketAccept()

      Returns the value of the `Sec-WebSocket-Accept` header.
      Returns:
        the value of the header

    - #### getSecWebSocketExtensions

          public List<WebSocketExtension> getSecWebSocketExtensions()

      Returns the value of the `Sec-WebSocket-Extensions` header.
      Returns:
        the value of the header

    - #### setSecWebSocketExtensions

          public void setSecWebSocketExtensions(List<WebSocketExtension> extensions)

      Sets the (new) value(s) of the `Sec-WebSocket-Extensions` header.
      Parameters:
        `extensions` - the values for the header

    - #### setSecWebSocketKey

          public void setSecWebSocketKey(String secWebSocketKey)

      Sets the (new) value of the `Sec-WebSocket-Key` header.
      Parameters:
        `secWebSocketKey` - the value of the header

    - #### getSecWebSocketKey

          public String getSecWebSocketKey()

      Returns the value of the `Sec-WebSocket-Key` header.
      Returns:
        the value of the header

    - #### setSecWebSocketProtocol

          public void setSecWebSocketProtocol(String secWebSocketProtocol)

      Sets the (new) value of the `Sec-WebSocket-Protocol` header.
      Parameters:
        `secWebSocketProtocol` - the value of the header

    - #### setSecWebSocketProtocol

          public void setSecWebSocketProtocol(List<String> secWebSocketProtocols)

      Sets the (new) value of the `Sec-WebSocket-Protocol` header.
      Parameters:
        `secWebSocketProtocols` - the value of the header

    - #### getSecWebSocketProtocol

          public List<String> getSecWebSocketProtocol()

      Returns the value of the `Sec-WebSocket-Key` header.
      Returns:
        the value of the header

    - #### setSecWebSocketVersion

          public void setSecWebSocketVersion(String secWebSocketVersion)

      Sets the (new) value of the `Sec-WebSocket-Version` header.
      Parameters:
        `secWebSocketVersion` - the value of the header

    - #### getSecWebSocketVersion

          public String getSecWebSocketVersion()

      Returns the value of the `Sec-WebSocket-Version` header.
      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:
        `getFirst` in interface `MultiValueMap<String,String>`
      Overrides:
        `getFirst` in class `HttpHeaders`
      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:
        `add` in interface `MultiValueMap<String,String>`
      Overrides:
        `add` in class `HttpHeaders`
      Parameters:
        `headerName` - the header name
        `headerValue` - 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:
        `set` in interface `MultiValueMap<String,String>`
      Overrides:
        `set` in class `HttpHeaders`
      Parameters:
        `headerName` - the header name
        `headerValue` - 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: `MultiValueMap`
      Set the given values under.
      Specified by:
        `setAll` in interface `MultiValueMap<String,String>`
      Overrides:
        `setAll` in class `HttpHeaders`
      Parameters:
        `values` - the values.

    - #### toSingleValueMap

          public Map<String,String> toSingleValueMap()

      Description copied from interface: `MultiValueMap`
      Returns the first values contained in this `MultiValueMap`.
      Specified by:
        `toSingleValueMap` in interface `MultiValueMap<String,String>`
      Overrides:
        `toSingleValueMap` in class `HttpHeaders`
      Returns:
        a single value representation of this map

    - #### size

          public int size()

      Specified by:
        `size` in interface `Map<String,List<String>>`
      Overrides:
        `size` in class `HttpHeaders`

    - #### isEmpty

          public boolean isEmpty()

      Specified by:
        `isEmpty` in interface `Map<String,List<String>>`
      Overrides:
        `isEmpty` in class `HttpHeaders`

    - #### containsKey

          public boolean containsKey(Object key)

      Specified by:
        `containsKey` in interface `Map<String,List<String>>`
      Overrides:
        `containsKey` in class `HttpHeaders`

    - #### containsValue

          public boolean containsValue(Object value)

      Specified by:
        `containsValue` in interface `Map<String,List<String>>`
      Overrides:
        `containsValue` in class `HttpHeaders`

    - #### get

          public List<String> get(Object key)

      Specified by:
        `get` in interface `Map<String,List<String>>`
      Overrides:
        `get` in class `HttpHeaders`

    - #### put

          public List<String> put(String key,
                                  List<String> value)

      Specified by:
        `put` in interface `Map<String,List<String>>`
      Overrides:
        `put` in class `HttpHeaders`

    - #### remove

          public List<String> remove(Object key)

      Specified by:
        `remove` in interface `Map<String,List<String>>`
      Overrides:
        `remove` in class `HttpHeaders`

    - #### putAll

          public void putAll(Map<? extends String,? extends List<String>> m)

      Specified by:
        `putAll` in interface `Map<String,List<String>>`
      Overrides:
        `putAll` in class `HttpHeaders`

    - #### clear

          public void clear()

      Specified by:
        `clear` in interface `Map<String,List<String>>`
      Overrides:
        `clear` in class `HttpHeaders`

    - #### keySet

          public Set<String> keySet()

      Specified by:
        `keySet` in interface `Map<String,List<String>>`
      Overrides:
        `keySet` in class `HttpHeaders`

    - #### values

          public Collection<List<String>> values()

      Specified by:
        `values` in interface `Map<String,List<String>>`
      Overrides:
        `values` in class `HttpHeaders`

    - #### entrySet

          public Set<Map.Entry<String,List<String>>> entrySet()

      Specified by:
        `entrySet` in interface `Map<String,List<String>>`
      Overrides:
        `entrySet` in class `HttpHeaders`

    - #### equals

          public boolean equals(Object other)

      Specified by:
        `equals` in interface `Map<String,List<String>>`
      Overrides:
        `equals` in class `HttpHeaders`

    - #### hashCode

          public int hashCode()

      Specified by:
        `hashCode` in interface `Map<String,List<String>>`
      Overrides:
        `hashCode` in class `HttpHeaders`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `HttpHeaders`